August 2004
Intermediate to advanced
480 pages
9h 41m
English
Examples in the Toolkit, such as the GaragePad doodler, show how to capture mouse motion events. There are also examples in the doodler application and the text editor that show how to handle action events from menu items when they're clicked.
In Swing, you create user controls for the user to interact with. When the user does something to a control—for example, clicks a button—that action fires an event. You create listeners that do something when that event is fired, and then attach them to the user controls. Actions can optionally hold information about tool tip text or icons, though this is rare.
Specifically, to handle an event you override the actionPerformed() method.
public void actionPerformed(ActionEvent evt) ...
Read now
Unlock full access