Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Aligning JLabels With BoxLayout

 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form that contains a bunch of JLabels and JTextfieds that will allow someone to edit a record. It will look something like so:



I am using BoxLayout to accomplish this JLabel right-justification. For the above example, I would create two horizontal boxes that are contained by one vertical box. I am using hBox.add(Box.createHorizontalStrut(int)) to move any shorter JLabels to the right so that they align properly.

I'm not sure if my method is font dependent. I'm afraid that on another machine, the JLabels would not be aligned if the system is using a different font. Is my method okay or is there a problem? Any suggestions? Thanks a lot in advance
[ June 04, 2004: Message edited by: Anthony Watson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic