浏览 1973 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2012-03-19
package net.etwo.jsplitpane.test; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.border.LineBorder; public class TestJSplitPane { private JFrame jframeMain = new JFrame(); private JPanel jpanelMain = new JPanel(); // 用于分割两个(只能两个)component private JSplitPane jsplitPaneTestOne = new JSplitPane(); // 上下 private JSplitPane jsplitPaneTextTwo = new JSplitPane( JSplitPane.VERTICAL_SPLIT); public TestJSplitPane() { // TODO Auto-generated constructor stub // 设置分隔条的位置 jsplitPaneTestOne.setDividerLocation(40); // 将组件分配到分隔符的左边 jsplitPaneTestOne.setLeftComponent(new JLabel("左边")); jsplitPaneTextTwo.setDividerLocation(80); //设置分隔条的大小 jsplitPaneTextTwo.setDividerSize(20); //快速展开/折叠分隔条(默认为false) jsplitPaneTextTwo.setOneTouchExpandable(true); jsplitPaneTextTwo.setLeftComponent(new JLabel("上面")); jsplitPaneTextTwo.setRightComponent(new JLabel("下面")); // 将组件分配到分隔符的右边 jsplitPaneTestOne.setRightComponent(jsplitPaneTextTwo); jpanelMain.setBorder(new LineBorder(Color.red)); //设置jpanelMain的布局管理 jpanelMain.setLayout(new BorderLayout()); jpanelMain.add(jsplitPaneTestOne); jframeMain.add(jpanelMain); jframeMain.setTitle("分割面板"); jframeMain.setSize(500, 600); jframeMain.setLocationRelativeTo(null); jframeMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jframeMain.setVisible(true); } public static void main(String[] args) { new TestJSplitPane(); } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |