- 论坛徽章:
- 0
|
- import java.awt.*;
- import java.awt.event.*;
- public class Test extends WindowAdapter
- {
- private Frame fr;
- private TextField tf;
-
- public static void main(String args[])
- {
- Test t = new Test();
- t.go();
- }
-
- public void go()
- {
- fr = new Frame("Close Window");
- fr.add(new Label("close"), BorderLayout.NORTH);
- tf = new TextField(30);
- fr.add(tf, BorderLayout.SOUTH);
-
- fr.addWindowListener(this);
- fr.pack();
- fr.setVisible(true);
- }
-
- public void windowClosing(WindowEvent e)
- {
- fr.dispose(); //这样会不会不妥?
- }
- }
复制代码
象上面, windowClosing里就把窗口给dispose()掉了
windowClosed会怎么样? |
|