本帖最后由 騛鹏 于 2013-3-31 01:44 编辑
- import java.awt.*;
- import java.awt.event.*;
- class FrameDemo
- {
- public static void main(String[] args)
- {
- Frame f = new Frame("it zi xun wang");
- //f.add(new Button("an niu"));
- f.setSize(500,600);
- f.setVisible(true);
- f.addWindowListener(new MyWindowListener());
- }
- }
- class MyWindowListener implements WindowListener
- {
- public void windowClosing(WindowEvent e)
- {
- e.getWindow().setVisible(true);
- try
- {
- Thread.sleep(3000);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- ((Window)e.getComponent()).dispose();
-
-
- System.exit(0);
- }
- public void windowActivated(WindowEvent e){}
- public void windowClosed(WindowEvent e){}
- public void windowDeactivated(WindowEvent e){}
- public void windowDeiconified(WindowEvent e){}
- public void windowIconified(WindowEvent e){}
- public void windowOpened(WindowEvent e){}
- }
复制代码 ((Window)e.getComponent()).dispose();
e.getComponent() 是如何用window转型的? 查API 也没有查明白? |