`

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

阅读更多
其实还可以通过评比关闭按钮的事件来达到该效果

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);
}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics