Event Summary
Table 13.1 and Table 13.2 summarize the commonly used Swing
events, which Swing
components fire them, and the methods of the listener interfaces that
receive them. The events and listeners are divided between the
java.awt.event and
javax.swing.event packages.
In Swing, a component’s model and view are distinct. Strictly
speaking, components don’t fire events; models do. When you
press a JButton, for example, it’s actually
the button’s data model that fires an
ActionEvent, not the button itself. But
JButton has a convenience method for registering
ActionListeners; this methods passes its argument
through to register the listener with the button model. In many cases
(as with JButtons), you don’t have to deal
with the data model separately from the view, so we can speak loosely
of the component itself firing the events.
Table 13-1. Swing Component and Container Events
|
Event |
Fired by |
Listener Interface |
Handler Method |
|---|---|---|---|
|
|
All components |
|
|
|
| |||
|
| |||
|
| |||
|
|
All components |
|
|
|
| |||
|
|
All components |
|
|
|
| |||
|
| |||
|
|
All components |
|
|
|
| |||
|
| |||
|
| |||
|
| |||
|
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access