• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Which is the best layout?

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I have about five JPanels that I want to add one after the other, vertically. Kind of like a FlowLayout, but vertical not horizontal. What is the best layout to use to accomplish this?
Thanks in advance!
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try:
yourPanel.setLayout(new BoxLayout(yourPanel, BoxLayout.Y_AXIS));
yourPanel.add(panel1);
.
.
yourPanel.add(panel5);
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I am trying to use Box Layout, however I have run into a problem. I made a tester class that had 5 different JLabels in it, sizes differing. It worked like I wanted it to. Now I'm trying to use the same class, but with JTextFields, while setting the columns, some long, some short. But when I run it, they are all the same size??? I thought BoxLayout respected preferred size? It does the same with ComboBoxes as well.
Am I missing something?
Any help would be GREATLY appreciated!
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have 5 panels you want to arrange vertically grid layout will be the easiest and provide the best results.
Set the grid 1 column wide and 5 rows tall. Then just add the panels to rows 0 - 4.
Michael Crutcher
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic