So, I have 2 JPanels of different Height. I want to vertical align them both to the top. What type of container should I use and how should I add them so they are both aligned to the top, not stretched in any way and they are not fixed (as in, if I change the size of one and it becomes bigger than the other one, I shouldn't modify the layout as well)
Asked
Active
Viewed 1,347 times
1
1 Answers
2
Honestly, I don't know if I completely understand what are your needs, anyway try to look at BoxLayout. It's very flexible and nesting vertical and horizontal BoxLayout, and with the use of glues and rigid area, you could create very nice GUI, which components resize automatically, when the frame change dimension.
Here's an example, but you can find a lot of others searching in the web.

Heisenbug
- 38,762
- 28
- 132
- 190
-
+1 for `BoxLayout`! Here's a related [example](http://stackoverflow.com/questions/5773874/jtabbedpane-jlabel-jtextfield/5773956#5773956). – trashgod May 03 '11 at 21:29