A line drawing program
Document your code using javadoc
Consider the task of creating a Java program that will allow the user to
create line drawings. Here is a start for such a program. Download the
program and examine it carefully. It allows users to draw lines on the yellow panel.
- Lines are drawn on the drawingPanel by:
- pressing the left mouse button down;
- then dragging the mouse while keeping the left mouse button pressed,
- and releasing it. A line is drawn from the point where the mouse
button was initially pressed to the point where the mouse was released. The current state of the line is always visible.
- Minimizing (or occluding) the window causes the lines to disappear. Why? Modify the code so that the lines are visible even after the window has been occluded.
- How would you solve this problem for one line?
- How would you extend the solution to many lines?
- Selecting File-New should erase all the lines. Add this functionality to your code.
- A left mouse click on a line while holding down the shift key must delete the line.
- Develop an algorithm to identify which line was clicked.
- Add this functionality to your code.