Java Reference
In-Depth Information
the program, and observe and report the results. Briefly explain what
you observe.
a. Change the page.drawPolyline method call to a page.
fillPolygon method call.
b. Change the fillPolygon parameter xWindow.length() to the
numeric literal "2" .
c. Switch the x and the y values in each of the arrays. For example
yWindow becomes {95, 105, 110, 90}.
d. A new, filled yellow polygon is drawn first with coordinates
(0, 100), (100, 0), (200, 100), and (100, 200).
e. A new, filled yellow polygon is drawn last with coordinates
(0, 100), (100, 0), (200, 100), and (100, 200).
8.8 Mouse Events
Let's examine the events that are generated when using a mouse. Java divides
these events into two categories: mouse events and mouse motion events . The
table in Figure 8.7 defines these events.
When you click the mouse button over a Java GUI component, three events are
generated: one when the mouse button is pushed down ( mouse pressed ) and two
when it is let up ( mouse released and mouse clicked ). A mouse click is defined
as pressing and releasing the mouse button in the same location. If you press
the mouse button down, move the mouse, and then release the mouse button, a
mouse clicked event is not generated.
Mouse Event
Description
mouse pressed
The mouse button is pressed down.
mouse released
mouse clicked
The mouse button is released.
The mouse button is pressed down and released without moving
the mouse in between.
mouse entered
The mouse pointer is moved onto (over) a component.
mouse exited
The mouse pointer is moved off of a component.
Mouse Motion Event
Description
mouse moved
The mouse is moved.
mouse dragged
The mouse is moved while the mouse button is pressed down.
FIGURE 8.7 Mouse events and mouse motion events
 
Search WWH ::




Custom Search