JAVA GUI学习 - JSplitPane分屏组件学习

 public class JSplitPaneKnow extends JFrame
{
JSplitPane jSplitPane;
JPanel jPanelRed;
JPanel jPanelBlue; public JSplitPaneKnow()
{
this.setBounds(300, 100, 400, 400);
this.setTitle("分屏设计");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jPanelBlue = new JPanel();
jPanelRed = new JPanel();
//第一个参数表示分屏的方式:左右HORIZONTAL_SPLIT,上下VERTICAL_SPLIT
jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,jPanelBlue,jPanelRed); jPanelBlue.setBackground(Color.BLUE);
jPanelRed.setBackground(Color.RED); this.add(jSplitPane); //设置分割线的位置
jSplitPane.setDividerLocation(200);
//设置分割线的大小
jSplitPane.setDividerSize(5);
//设置分割线是否可以随意拉动
jSplitPane.setEnabled(false);
}
public static void main(String[] args)
{
JSplitPaneKnow jSplitPaneKnow = new JSplitPaneKnow();
jSplitPaneKnow.setVisible(true);
}
}
上一篇:[android] 保存文件到SD卡


下一篇:Node.js的模块载入方式与机制