GUI小程序【splitpane】

学习需要,想做一个可以改变大小的面板,java学的不是很好, 不知道怎么弄后来搜索下了,可以使用JSplitPane,比较简单 下面是一个简单演示: 




import java.awt.*;

import javax.swing.*;

public class MysplitpaneDemo extends JFrame{
private JButton jb1,jb2;
private JSplitPane jsplitpane1,jsplitpane2;
private JScrollPane jsp;
private JLabel jlabel1,jlabel2;

public MysplitpaneDemo(){
super();
initilize();

}

public void initilize(){
JFrame frame=new JFrame("splitpane");
jlabel1=new JLabel("Emy_Love_javaeye_left",JLabel.CENTER);
jlabel2=new JLabel("Emy_Love_javaeye_right",JLabel.CENTER);

jsplitpane1=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                jlabel1,jlabel2);

jsplitpane1.setOneTouchExpandable(true);
jsplitpane1.setDividerLocation(150);

jlabel1.setMinimumSize(new Dimension(100, 30));
jlabel2.setMinimumSize(new Dimension(100,30));

frame.getContentPane().add(jsplitpane1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(700,600);
frame.setLocation(100,100);
frame.setVisible(true);



}

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new MysplitpaneDemo();

}

}

你可能感兴趣的:(java,jsp,swing)