Win a copy of Microservices in Action this week in the Web Services forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Best Layout For 2 JLabels  RSS feed

 
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.
 
Bartender
Posts: 9498
184
  • 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!