• 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 ]
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!