example.java

来自「介绍有关java的资料 课件 相当一本书籍 里面都是很基础的知识」· Java 代码 · 共 45 行

JAVA
45
字号
		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 + =
减小字号Ctrl + -
显示快捷键?