Mouse Events from Frame Event

If you click in the FrameEvent frame, you'll getthe mousePressed,mouseClicked, and mouseReleased mouse events. If you hold the mouse button down and drag it, you'll get the mouseDra gged event. If you move the mouse pointer anywhere in the work area of the frame (or any place but the caption [titlebar] and system menus), you'll get the mouseMoved event. Table 15-3 lists the mouse events.

Try these exercises:

• Click on the frame's work area wish both ehe right and the left buttons. What's the difference in the output?

• This sample applicatk)n was written in AWT components, which are eimilar to S wing components. Convert to JFC/Swing, (The component events must be set up with JFrame'scontentPane.)

Table 15-3. Mouse Events and Event Properties


Listener Interface

P ro perty


MouseLis tener

mouseClicked mouseEntered mouseExited mousePressed mouseReleased



mouseDragged mouseMoved

Was this article helpful?

0 0

Post a comment