CSC 333

Homework 4

Assigned Oct. 21, due Nov. 11

In this assignment we'll start adding interactivity to the program.
  1. In a separate program, practice building Buttons, TextFields, Labels, Panels, etc. Add listeners so they can do something interesting.
  2. Modify your program from Homework 3 so that the drawing happens in a Canvas (you'll need to write a subclass of Canvas, e.g. NodeCanvas) whose paint() method does what your Applet's paint() method currently does. Add this Canvas and a couple of non-functional Buttons to the Applet, so you can confirm that the Canvas is only part of the window. Make sure everything that worked in Homework 3 still works.
  3. When the user clicks the left mouse button in the Canvas, your program should create a new node (the kind with two pointers) at the current mouse location. (This entails adding a MouseListener to the Canvas.)
  4. The aforementioned box should be created with null-pointer symbols (either the "ground" symbol I used in the above picture, or a diagonal slash through the box) for each of its two pointers.
  5. After the first mouse-click, each subsequent mouse-click should create not only a new node, but an arrow from the right half of the previously-created node to the new one.
  6. Add a "clear" button to the button region of the screen, with the behavior that when it is pressed, all objects disappear from the main drawing canvas; subsequent nodes can be added as above.
  7. Allow the user to select an existing node by clicking inside it; this should highlight the old node rather than creating a new one. When the user clicks somewhere else, the highlighted node should be un-highlighted.
  8. Add other interesting buttons, like "Delete" (which deletes the currently selected node and all arrows leading to or from it), etc.

Last modified:
Stephen Bloch / sbloch@adelphi.edu