⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 canvas.java

📁 介绍有关java的资料 课件 相当一本书籍 里面都是很基础的知识
💻 JAVA
字号:
		import java.awt.*;		import java.applet.Applet;		public class canvas extends Applet {			Button b1;                        TextField xValue;                        TextField yValue;			public void init() {				setLayout(new BorderLayout(15,15));				b1 = new Button("Test");                                xValue = new TextField("0",5);                                yValue = new TextField("0",5);				myCanvas c1 = new myCanvas(100,100);				add("Center",c1);				add("South",b1);                                add("East",xValue);                                add("West",yValue);			}			public boolean action(Event e, Object arg) {                                TextField xValue = new TextField("0",5);                                TextField yValue = new TextField("0",5);				//System.out.println("Event: " + arg);                                xValue.setText("Event: " + arg);                                yValue.setText("y");				return true;			}			public boolean mouseDown(Event e, int x, int y) {				System.out.println("Mouse works: (" + x + "," + y + ")");				return true;			}		}		class myCanvas extends Canvas {			private int width;			private int height;			public myCanvas(int w,int h) {				width = w;				height = h;				reshape(0,0,w,h);			}			public void paint(Graphics g) {				g.setColor(Color.blue);				g.fillRect(0, 0, width, height);			}			public boolean mouseDown(Event e, int x, int y) {                                TextField xValue = new TextField("0",5);                                TextField yValue = new TextField("0",5);				if (( x < width) && (y <height)) {					xValue.setText(Integer.toString(x));                                        yValue.setText(Integer.toString(y));					return true;					//有鼠标按下				}				return false;						//没有鼠标按下			}		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -