当前位置: 代码迷 >> Java相关 >> [求助]这个程序,到底是哪有问题(切分窗口的)
  详细解决方案

[求助]这个程序,到底是哪有问题(切分窗口的)

热度:133   发布时间:2007-06-21 22:25:39.0
[求助]这个程序,到底是哪有问题(切分窗口的)

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();
}
}

搜索更多相关的解决方案: 切分  窗口  

----------------解决方案--------------------------------------------------------
重新更新一下组件树
----------------解决方案--------------------------------------------------------
什么叫组件树?~~~~
----------------解决方案--------------------------------------------------------
SwingUtilities.updateComponentTreeUI(Component com)

这个方法,我不知道记错了没有,你最好还是查一下SwingUtilities的API

我手头上没有环境,
----------------解决方案--------------------------------------------------------
  相关解决方案