FileDocCategorySizeDatePackage
GfxDemoCanvas.javaAPI DocExample894Mon Jan 31 23:05:16 GMT 2000None

GfxDemoCanvas

public class GfxDemoCanvas extends Canvas
Fancier, Canvas-based Graphics Demo for Learning Tree Course 471/478 This subclass of Canvas does the drawing; GfxDemo2 merely creates a Frame and adds the Canvas to it, while PrintDemoGFx creates one of these and calls its paint() method with a Printer Graphics object.
author
Ian Darwin, ian@darwinsys.com

Fields Summary
int
width
int
height
Constructors Summary
GfxDemoCanvas(int w, int h)

		setSize(width=w, height=h);
	
Methods Summary
public java.awt.DimensiongetPreferredSize()

		return new Dimension(width, height);
	
public voidpaint(java.awt.Graphics g)

		width = getSize().width;
		height = getSize().height;
		g.setColor(Color.black);
		g.drawRect(0, 0, width-1, height-1);
		g.setColor(Color.red);
		g.fillRect(0, 0, width/2, height/2);
		g.setColor(Color.blue);
		g.drawString("Welcome to My Blue Heaven", (width/2)+10, (height/2)+10);