copytest2.java

来自「java2图形设计卷1:awt 源码」· Java 代码 · 共 24 行

JAVA
24
字号
import java.applet.Applet;
import java.awt.*;

public class CopyTest2 extends Applet {
	public void paint(Graphics g) {
		setForeground(Color.yellow);

		// the next line would do just as well as the following
		// g.setColor(Color.yellow);

		Graphics copy = getGraphics();
		try {
			System.out.println("g=" + g.getColor() + 
								" copy=" + copy.getColor());

			copy.drawLine(0,0,
							getSize().width-1, getSize().height-1);
		}
		finally {
			copy.dispose();
		}
	}
}

⌨️ 快捷键说明

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