O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sensing Double Clicking

Sensing that the mouse has been double-clicked requires use of the Event clickCount field. To illustrate this, we've written the DoubleClickApplet program, which is set up like the previous event applets in this chapter. Example 8-3 shows the DoubleClickApplet code.

Example 8-3. DoubleClickApplet Class Listing
 import java.applet.Applet; import java.awt.*; public class DoubleClickApplet extends Applet { public void init() { setLayout(new BorderLayout()); add(new DoubleClickCanvas(), "Center"); } } class DoubleClickCanvas extends Canvas { public boolean mouseDown(Event event, int x, int y) { if(event.clickCount == 2) System.out.println("Double ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required