首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

Swing的JFrame窗体跳转及关闭有关问题

2012-12-15 
Swing的JFrame窗体跳转及关闭问题我通过窗体A 调用 窗体 B,点击窗体B右上角的x关闭窗体B,然后就退出整个程

Swing的JFrame窗体跳转及关闭问题
我通过窗体A 调用 窗体 B,点击窗体B右上角的x关闭窗体B,然后就退出整个程序了
请问怎么才能关闭B,但是保留A呢
A是用SwingUtilities.invokeLater执行的
A的调用代码:

ChatView.main(null);

B:
public static void main(String[] args) throws InvocationTargetException, InterruptedException{
SwingUtilities.invokeLater(new Runnable(){
public void run() {
JFrame.setDefaultLookAndFeelDecorated(true);  
JDialog.setDefaultLookAndFeelDecorated(true);  
 try {
 //设置皮肤
            UIManager.setLookAndFeel( new  SubstanceOfficeBlue2007LookAndFeel()); 
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();

 
ChatView cv = new ChatView();
name = "大肚腩";
cv.setTitle(name);
cv.setSize(500,400);

//cv.setResizable(false);  //不允许用户改变窗口大小
cv.setDefaultCloseOperation(EXIT_ON_CLOSE);
// com.sun.awt.AWTUtilities.setWindowOpacity(cv, .7f);
cv.setVisible(true);
cv.setLocationRelativeTo(null);
}
});
}

[最优解释]
不要使用 setDefaultCloseOperation(EXIT_ON_CLOSE),使用 DISPOSE_ON_CLOSE
[其他解释]
谢谢,解决了

热点排行