📄 myframe.java
字号:
import java.awt.event.*;import javax.swing.*;public class MyFrame extends JFrame { public MyFrame() { // declare an inner class that extends an adapter class class MyWindowAdapter extends WindowAdapter { // only do something when the window is closing public void windowClosing(WindowEvent e) { System.out.println("Window about to close"); System.exit(0); } } this.addWindowListener( new MyWindowAdapter() ); // use an anonymous adapter class instead this.addWindowListener( new WindowAdapter() { // only do something when the window is activated public void windowActivated(WindowEvent e) { System.out.println("Window is active"); } } ); } public static void main(String[] args) { MyFrame frame = new MyFrame(); frame.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -