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

📄 testpattern.java

📁 exploring Java 2ed edition 附带的例子程序
💻 JAVA
字号:
import java.awt.*;import java.awt.event.*;public class TestPattern extends java.applet.Applet { 	int theta = 45;	public void paint( Graphics g ) {		int Width = size().width;		int Height = size().height;		int width = Width/2;		int height = Height/2;		int x = (Width - width)/2;		int y = (Height- height)/2;		int [] polyx =  { 0, Width/2, Width, Width/2 };		int [] polyy =  { Height/2, 0, Height/2, Height };		Polygon poly = new Polygon( polyx, polyy, 4 );				g.setColor( Color.black );		g.fillRect( 0, 0, size().width, size().height );		g.setColor( Color.yellow );		g.fillPolygon( poly );		g.setColor( Color.red );		g.fillRect( x, y, width, height );		g.setColor( Color.green );		g.fillOval( x, y, width, height );		g.setColor( Color.blue );		int delta = 90;		g.fillArc( x, y, width, height, theta, delta );		g.setColor( Color.white );		g.drawLine( x, y, x+width, x+height );	}	public void init() {		addMouseListener( new MouseAdapter() {			public void mousePressed( MouseEvent e ) {				theta = (theta + 10) % 360;				repaint();			}		} );	}}

⌨️ 快捷键说明

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