FileDocCategorySizeDatePackage
TestPattern.javaAPI DocExample1082Tue Mar 25 13:07:40 GMT 1997None

TestPattern

public class TestPattern extends Applet

Fields Summary
int
theta
Constructors Summary
Methods Summary
public voidinit()

		addMouseListener( new MouseAdapter() {
			public void mousePressed( MouseEvent e ) {
				theta = (theta + 10) % 360;
				repaint();
			}
		} );
	
public voidpaint(java.awt.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 );