当前位置: 代码迷 >> J2SE >> 怎么判断一个框体是否关闭了?求解
  详细解决方案

怎么判断一个框体是否关闭了?求解

热度:809   发布时间:2013-02-25 00:00:00.0
如何判断一个框体是否关闭了?求解
有两个框体JFrame jf1,jf2
当jf2出现时jf1设为不可见;
当jf2关闭时jf1又可见了。求解答!
如何判断jf2已经关闭了?

------解决方案--------------------------------------------------------
加个监听不就完了
Java code
        Frame f = new Frame();                f.addWindowListener(new WindowListener() {            @Override            public void windowActivated(WindowEvent arg0) {                // TODO Auto-generated method stub                            }            @Override            public void windowClosed(WindowEvent arg0) {                // TODO Auto-generated method stub                System.out.println("关闭");            }            @Override            public void windowClosing(WindowEvent arg0) {                // TODO Auto-generated method stub                            }            @Override            public void windowDeactivated(WindowEvent arg0) {                // TODO Auto-generated method stub                            }            @Override            public void windowDeiconified(WindowEvent arg0) {                // TODO Auto-generated method stub                            }            @Override            public void windowIconified(WindowEvent arg0) {                // TODO Auto-generated method stub                            }            @Override            public void windowOpened(WindowEvent arg0) {                // TODO Auto-generated method stub                            }        });
------解决方案--------------------------------------------------------
开启F2的时候 设置F1 visible = false 
开启F1的时候 设置F2 visible = false 

------解决方案--------------------------------------------------------
boolean flag标记一下。通过flag判断。
  相关解决方案