[an error occurred while processing this directive]
Start Messages Contents Index Links Contact

Week 25 - 2002: Drawing tool

It has been a long time since last exercises. To fresh up a bit, we will make a small drawing tool this week.
 

First, create a JFrame that reports the mouse events by System.out.println statements. These events include clicking, moving, dragging, etc.
Hint: javax.swing.event.MouseInputListener (since JDK 1.4)
 

Now extend your JFrame to respond to mouse clicking and dragging by drawing a trail where the cursor is dragged. The result should be a very simple drawing program.
Could you imagine some way to save and load your drawings? There are several different ways this could be implemented: Saving and Image object, image file (GIF, JPEG, etc.) or saving the coordinates of the marked pictures, to mention some.

 



generated: April 26, 2003