欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

禁用swing窗体右上角关闭按钮

程序员文章站 2022-06-08 23:13:00
...
import java.awt.*; 
import javax.swing.*;
import java.awt.event.*;

class MyFrame extends JFrame {
MyFrame() {
}

protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
} else {
super.processWindowEvent(e);
}

}

public static void main(String[] args) {
MyFrame frame = new MyFrame();
frame.setSize(new Dimension(500, 500));
frame.setVisible(true);
}
}



//窗口事件
this.addWindowListener(new WindowListener()
{
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowClosing(WindowEvent e){}//sysTray.remove(trayIco);}
public void windowDeactivated(WindowEvent e){}//setVisible(false);requestFocus();}//显示最前
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){}
});
相关标签: Swing Java