Hello,
I am programming a GUI witch a JFrame containing a JScrollPane, which has a JPanel (my mainPanel, BoxLayout.Y_Axis) as its viewPortView.
I can add muliple JPanels to the mainPanel with button clicks. Defined by the BoxLayout these panels align top-down.
Attached a picture of my frame with 3 added panels.
Now my need/problem:
These panels heights should be resizable by mouse (drag/drop) similar to the JSplitPane. But JSplitPane does only support 2 components. Otherwise I needed nested once, which is pretty ugly.
My Approach:
After some research I found this to resize my panels:
http://groups.google.com/group/de.comp.lang.java/browse_thread/thread/3a23402f8871f10c
But when I use this I need to invoke setpreferredSize(Dimension) explicitly and that makes my BoxLayout fail, when I change my window size. That means, if a resize the main window smaller than preferred size of the panels, my panels do not resize automatically like before.
My Question:
Do you know a better solution or is there even an existing one out there to resize JPanels within a main panel?
Or can you help me out with the automatic "fit-to-windowsize" after invoking setpreferredSize(...)?
I tried a lot, but no approach fullfills my requierements. Sorry for bothering you again.