📄 example.java
字号:
import java.awt.*; public class Example extends Frame { public String motd; public Example(String s){ super("程序示范"); //set title motd = s; resize(300,100); } public Example(){ this("这是一个鼠标按键事件处理示范程序"); } public void paint(Graphics g){ g.drawString(motd,20,50); g.drawString("使用鼠标点击程序框架内任何处,则退出该程序",20,75); } public boolean mouseDown(Event e,int x,int y) { hide(); //hide the window dispose(); System.exit(0); //Quit return false; } public boolean handleEvent(Event e) { if (e.id == Event.WINDOW_DESTROY) { dispose(); System.exit(1); return true; } else { super.handleEvent(e); } return false; } public static void main(String args[]) { Example m; if (args.length > 1) { m = new Example(args[0]); } else { m = new Example(); } m.show(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -