
Table 2−8: Swing Event Listeners and the Components That Use Them (continued)
Event Listener Listener Methods Register ed on
ListSelectionListener valueChanged() JList,
ListSelectionModel
MenuDragMouseListener menuDragMouseDragged(),
menuDragMouseEntered(),
menuDragMouseExited(),
menuDragMouseReleased()
JMenuItem
MenuKeyListener menuKeyPressed(),
menuKeyReleased(),
menuKeyTyped()
JMenuItem
MenuListener menuCanceled(),
menuDeselected(),
menuSelected()
JMenu
PopupMenuListener popupMenuCanceled(), JPopupMenu
popupMenuWillBecome-
Invisible(),
popupMenuWillBecome-
Visible()
TreeExpansionListener treeCollapsed(),
treeExpanded()
JTree
TreeSelectionListener valueChanged() JTree
TreeWillExpandListener treeWillCollapse(),
treeWillExpand()
JTree
java.beans.- propertyChange() Action, JComponent,
PropertyChangeListener UIDefaults, UIManager
java.beans.- vetoableChange() JComponent
VetoableChangeListener
Swing Component Architecture
So far, we have treated components as single, self-contained GUI building blocks.
And indeed, components can be written to be entirely self-contained. However,
neither AWT nor Swing components are actually self-contained. As I mentioned
earlier, each AWT component is simply a frontend for an underlying native user-
inter face object. AWT delegates all the display and event processing — that is, the
look-and-feel — to these native GUI elements.
Swing components are not self-contained either. Most Swing ...