1

我有一个相当简单的对话框,其中包含一对大小大致相等的 JPanel,包含在 JSplitPane 中。现在我正在考虑添加第三个 JPanel,但我不太确定是否有明显的解决方案。那里有一个好的窗口停靠框架吗?或者这是一件非常复杂的事情?如果我只是坚持使用 3 面板拆分,我是否必须使用一对嵌套的 JSplitPanes 或者是否有允许 3 向拆分的替代方案?

4

2 回答 2

5

SwingX库有JXMultiSplitPane类,它允许您创建可调整大小面板的任何布局。

关于它的一篇非常好的文章位于http://today.java.net/pub/a/today/2006/03/23/multi-split-pane.html

于 2009-08-04T19:55:10.000 回答
1

假设您有三个面板:

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 );
于 2011-11-13T11:30:07.827 回答