raindrop.java

来自「外文网站上下载的JSP图形编程(3)」· Java 代码 · 共 36 行

JAVA
36
字号
import java.awt.Graphics;

/*
 * Created on Jul 3, 2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

/**
 * @author Fabian Jones AD Summer Intern 2003
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class RainDrop{
	protected int x, y, velocity;
	private static int DELTA = 5;

	public RainDrop(int _x, int _y){
		this(_x, _y, 0);
	}
	
	public RainDrop(int _x, int _y, int _v){
		this.x = _x;
		this.y = _y;
		this.velocity = _v;
	}
	
	public void paint(Graphics g){
		g.drawLine(x, y, x+DELTA, y+DELTA);
		x = x + DELTA + velocity;
		y = y + DELTA + velocity;
	}
}

⌨️ 快捷键说明

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