import java.awt.*;
import java.awt.event.*;
public class Main {
public static void main(String []args)
{
Frame f=new Frame("我的窗口");
f.setSize(400,300);
f.setLocation(300,200);
f.setVisible(true);
MyWindowListener mw=new MyWindowListener();
f.addWindowListener(mw);
}
}
class MyWindowListener implements WindowListener{
public void windowClosing(WindowEvent e)
{
Window window=e.getWindow();
window.setVisible(false);
window.dispose();
}
public void windowActivated(WindowEvent e)
{
}
public void windowClosed(WindowEvent e)
{
}
public void windowDeact(WindowEvent e)
{
}
public void windowDeiconified(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowOpened(WindowEvent e)
{
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}
第一个可关闭Frame界面
最新推荐文章于 2021-03-13 15:34:32 发布