Lab 1 Java

Final Presentation Minimum: Make an applet with a menu which lets the user

Useful Preparation (steps in getting to the final product - not to turn in):

  1. Create an applet, DrawBox.java that allows the user to draw a box in your applet space The upper left corner should be recorded on a mousePressed event. The lower right corner should be recorded in the mouseReleased event. At first, do not worry about showing a "rubberband box" as the user drags the mouse, just draw the final box.

  2. Make the Drawbox more robust by allowing the user to use the mouse to set any two points as the diagonal corners of the box. Think about all the possible combinations of starting and stopping points a user could enter. How do those translate into coordinates that drawRect() can use?

  3. Add support to the "rubberbanding" effect when drawing your box by using another mouse event: mouseDragged. Like mousePressed and mouseReleased, you can redefine the mouseDragged method: Java generates mouseDragged events when the user presses a mouse button and moves the mouse before releasing the button.

    See some examples for help when you give up...