import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class ResiltMenu implements ActionListener
{
private JFrame jframe2;
private JButton bt;
private JSplitPane jsp;
private int orie; //标记方向
private JPanel p1,p2,p3;
public ResiltMenu()
{
Container cp= jframe2.getContentPane();
p1=new JPanel();
p2=new JPanel();
p3=new JPanel();
bt=new JButton("Change Qrientation");
cp.setLayout(new BorderLayout());
p3.setLayout(new FlowLayout());
jsp=new JSplitPane(JSplitPane.VERTICAL_SPLIT,p1,p2);
jsp.setOneTouchExpandable(true);
cp.add(jsp, BorderLayout.CENTER);
p3.add(bt);
jframe2.add(p3,BorderLayout.SOUTH);
bt.addActionListener(this);
p1.setBackground(Color.gray);
p2.setBackground(Color.white);
orie=0;
jframe2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe2.setSize(400,300);
jframe2.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==bt)
{
if(orie==0)
{
jsp.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
orie=1;
}
else
{
jsp.setOrientation(JSplitPane.VERTICAL_SPLIT);
orie=0;
}
}
}
public static void main(String[] args)
{
new ResiltMenu();
}
}