Question

I had a fairly simple dialog with a pair of JPanels of roughly equal size, contained in a JSplitPane. Now I'm looking at adding a 3rd JPanel and I'm not so sure there is an obvious solution. Is there a good window-docking framework out there? or is that a horribly complex thing to get into? If I do just stick with the 3-panel split, do I have to use a pair of nested JSplitPanes or is there an alternative that allows a 3-way split?

Was it helpful?

Solution

SwingX library has JXMultiSplitPane class which allows you to create any layouts of resizable panels.

A very good article about it is at http://today.java.net/pub/a/today/2006/03/23/multi-split-pane.html

OTHER TIPS

Let's say you have three panels:

JPanel panel1;
JPanel panel2;
JPanel panel3;

// set up panels
...

// put three panels into a horizontal split pane,
// with 2 resizeable dividers
JSplitPane splitPaneLeft = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
JSplitPane splitPaneRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPaneLeft.setLeftComponent( panel1 );
splitPaneLeft.setRightComponent( panel2 );
splitPaneRight.setLeftComponent( splitPaneLeft );
splitPaneRight.setRightComponent( panel3 );

// put splitPaneRight onto a single panel
JPanel panelSplit = new JPanel();
panelSplit.add( splitPaneRight );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top