Click ABOVE the line to clear the canvas and see the Canvas Cleared message.
// Written by Mark Jacobson - show(), hide(), clearCanvas(), if, etc. // Also shows the first PRIVATE method example - drawSetup() is private. // Tuesday, January 28th, 2003 - Note the VWS (Vertical White Space) // - Note also the INDENTATION style... import objectdraw.*; import java.awt.*; public class HelloWorld2 extends WindowController { private Text clearMessage; private FilledRect clearLine; public void begin() { drawSetup(); } public void onMousePress(Location point) { double x = point.getX() + 25; double y = point.getY(); new Text("Go Panthers", x, y, canvas).setColor( Color.magenta ); clearMessage.hide(); } public void onMouseRelease(Location point) { if ( point.getY() < clearLine.getY() ) { canvas.clear(); drawSetup(); clearMessage.show(); } } private void drawSetup() { clearLine = new FilledRect(0, 25, 500, 2, canvas); clearMessage = new Text("Canvas cleared!", 100, 2, canvas); clearMessage.setFont("Courier New"); clearMessage.setColor( Color.blue ); clearMessage.setFontSize( 22 ); clearMessage.hide(); } }