Java Reference
In-Depth Information
13. Event sources report on events. When an event occurs, the event source notifies
all event listeners.
14. Use
JButton
components for buttons. Attach an
ActionListener
to each
button.
15. Methods of an inner class can access local variables from surrounding blocks
and fields from surrounding classes.
16. Local variables that are accessed by an inner-class method must be declared as
final
.
17. Use a
JPanel
container to group multiple user-interface components together.
18. You often install event listeners as inner classes so that they can have access to
the surrounding fields, methods, and final variables.
19. A timer generates timer events at fixed intervals.
428
429
20. The
repaint
method causes a component to repaint itself. Call this method
whenever you modify the shapes that the
paintComponent
method draws.
21. You use a mouse listener to capture mouse events.
CLASSES, OBJECTS, AND METHODS INTRODUCED IN THIS
CHAPTER
java.awt.Component
addMouseListener
repaint
java.awt.Container
add
java.awt.Rectangle
setLocation
java.awt.event.MouseEvent
getX
getY
java.awt.event.ActionListener
actionPerformed
java.awt.event.MouseListener
mouseClicked