MyCanvas

MyCanvas - public void componentResized(ComponentEvent e) {...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import acm.graphics.*;import java.awt.event.*;public class MyCanvas extends GCanvas implements ComponentListener { public MyCanvas() { addComponentListener(this); rect = new GRect(BOX_WIDTH, BOX_HEIGHT); rect.setFilled(true); } public void update() { removeAll(); add(rect, (getWidth() - BOX_WIDTH) / 2, (getHeight() - BOX_HEIGHT) / 2); } // Must have these methods, even if they don't do anything
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public void componentResized(ComponentEvent e) { update();}public void componentHidden(ComponentEvent e) { } public void componentMoved(ComponentEvent e) { } public void componentShown(ComponentEvent e) { } p private static final double BOX_WIDTH = 50; private static final double BOX_HEIGHT = 50; private GRect rect; }...
View Full Document

This note was uploaded on 02/18/2010 for the course CS 106A taught by Professor Sahami,m during the Fall '08 term at Stanford.

Ask a homework question - tutors are online