// Written by Mark Jacobson on Wednesday, August 28th, 2002. // Study this as you carefully read, reread, review and refer to // the library purchased packet - // Everything here is a review of chapter one of the Williams College // manuscript. Note that the Williams College text urges you to // NOT concern yourself with some portions of the syntax at all, // but think of them as magical incantations, like abbra cadabra. // -------------------- // You need to just imitate and recite these magical incantations // for your first program, without worrying about the why or what // they mean. That will come later, when you are ready, after more // groundwork is laid down and experience is gained. import objectdraw.*; import java.awt.*; public class SimplestBox extends WindowController { public void begin() { new FilledRect(50, 100, 35, 105, canvas); FilledRect redRect = new FilledRect(60, 145, 15, 15, canvas); redRect.setColor(Color.red); new Text("Written by Mark Jacobson", 50, 220, canvas); Text dateMessage = new Text("810:061 demo on August 28th, 2002", 50, 250, canvas); dateMessage.setColor(Color.blue); Line myRuler1, myRuler2; myRuler1 = new Line(50, 240, 189, 240, canvas); myRuler2 = new Line(50, 241, 189, 241, canvas); myRuler1.setColor(Color.green); myRuler2.setColor(Color.green); } }
6 different Constructors for Graphic Objects ------------ new Line( startX, startY, endX, endY, canvas); new FramedRect( x, y, width, height, canvas); new FilledRect( x, y, width, height, canvas); new FramedOval( x, y, width, height, canvas); new FilledOval( x, y, width, height, canvas); new Text( "some message", x, y, canvas); This is the one METHOD that was shown. someColor could be Color.blue ------ or Color.red or Color.green. someObject.setColor( someColor );