• Post Reply Bookmark Topic Watch Topic
  • New Topic

Urgent Swing help needed  RSS feed

 
Keith Mc C
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the middle of a Swing assessment for a job im going for (has to be done in next hour)

am wasting time trying to figure out how to display my JTextfields and align them when i should be coding the rest of the project

Its been a couple of years since i did any swing so cant remember much..

basically what i need is 2 columns the first has all the field titles (i.e PersonID, First Name, DOB ...etc) uneditable
the second will have corresponding editable JTextfields that will contain the data for each person

I know this is simple but like i said im rusty so a couple of lines showing how to get setlayout and get them in the roght place would be greatly appreciated
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from your description, generally, you would have two gridlayout panels, both (0,1)
the labels would be added to the first gridlayout
the textfields added to the second

the gridlayout panels would be added to a borderlayout panel
label gridlayout to borderlayout.west
textfield gridlayout to borderlayout.center

the labels/textfields should line up alongside each other,
and if the frame is dragged wider, the additional space will go to the textfields
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keith Mc C wrote:Urgent Swing help needed [...] (has to be done in next hour)

Please EaseUp. You may be in a hurry, but we are all volunteers with our own jobs. I myself am now on my break.

Also, next time UseAMeaningfulSubjectLine. 99% of the posts in this sub forum are about request for help with Swing.
 
Keith Mc C
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn wrote:from your description, generally, you would have two gridlayout panels, both (0,1)
the labels would be added to the first gridlayout
the textfields added to the second

the gridlayout panels would be added to a borderlayout panel
label gridlayout to borderlayout.west
textfield gridlayout to borderlayout.center

the labels/textfields should line up alongside each other,
and if the frame is dragged wider, the additional space will go to the textfields


Thanks Michael, found that very helpful.

Unfortunately didnt get alot of the functionality done in the time allocated but at least the GUI was readable and I got the data that was read in from file displayed on it.

Better brush up on my swing for future, thanks again. Keith.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!