Objectdraw

☆There are seven mouse actions ☆ - you can add these to any program that "extends WindowController" - public void onMousePress(Location point) - public void onMouseRelease (Location point) - public void onMouseClick (Location point) - public void onMouseMove (Location point) - public void onMouseDrag (Location point) - public void onMouseEnter (Location point) - public void onMouseExit (Location point)
 * Mouse Actions (Ojbectdraw)**

code public void begin code || Initialize the program. || code public void onMouseClick(Location point) code || Define actions to take when the mouse button is clicked. || code public void onMousePress(Location point) code || Define actions to take when the mouse button is pressed. || code public void onMouseRelease(Location point) code || Define actions to take when the mouse button is released. || code public void onMouseEnter(Location point) code || Define actions to take when the mouse enters the window. || code public void onMouseExit(Location point) code || Define actions to take when the mouse exits the window. || code public void onMouseDrag(Location point) code || Define actions to take when the mouse is moved with the mouse button down. || code public void onMouseMove(Location point) code || Define actions to take when the mouse is moved with the mouse button up. ||


 * public void begin **

Programs written by extending Controller can perform any required initialization by defining a begin method containing the code to perform the initialization steps. You can make objects like citcle, rectangle (Filled or Framed), line, and text. More information about making objects look __Drawable. Objects__

Example :

public void begin { box = new FilledRect( 140, 140, 120, 120, canvas); //the yellow rectangle// box. setColor(Color. yellow); //sets the color of the rectangle to yellow// hello = new FramedRect( 140, 140, 120, 120, canvas); //the rectangle itself// love = new FilledRect( 198, 260, 8, 175, canvas); //the bar that connect the base and the sign// steve = new FramedOval( 147, 148, 105, 105, canvas); //the circle in the rectangle// Line2 = new Line( 140, 434, 260, 434, canvas); //the base// bob = new Line( 161, 166, 236, 239, canvas); //the diagonal line in the circle// message = new Text( "CLICKING", 176, 194, canvas); //text box }


 * void onMouseDrag(Location point)**

Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the component where the first originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component). __Steps__ 1. keep track of last mouse location. 2. compare that to current location. 3. subtract current x- Last x for change in x same for y's 4. move each object change x & y. 5. update get Mouse location.