11.8. A Whiteboard Class

Listing 11.11 shows an applet that lets the user create freehand drawings. The idea is to record the initial x and y position when the user presses the mouse and then to draw line segments from the previous position to the current position as the user drags the mouse. For example, Figure 11-5 shows a map to the Kossiakoff Center at the Johns Hopkins University Applied Physics Lab, and indicates where to park once there.

Figure 11-5. A simple whiteboard; drawing is performed when the mouse is dragged.

Listing 11.11. SimpleWhiteboard.java
 import java.applet.Applet; import java.awt.*; import java.awt.event.*; /** An applet ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.