• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Urgent Swing help needed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22650
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic