• Post Reply Bookmark Topic Watch Topic
  • New Topic

Best Layout For 2 JLabels  RSS feed

 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone advise me on the best Layout for 2 JLabels inside a JPanel. The Labels should always be side by side, instead of one on top of the other, and stuck at opposite ends of the JPanel, but in the case of the one on the right, it should not shift when text in it is changed. Thanks so much for your help.
 
Stephan van Hulst
Saloon Keeper
Posts: 6999
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Isaac,

From the top of my mind, BoxLayout would be good for this. You can add a label, then add some glue, and add your second label. The glue will take up the extra space. Take a look at Box.createHorizontalGlue().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!