The action() method is an especially important event-handling method. Only basic control components -- Button, Checkbox, Choice, List, MenuItem, and TextField objects -- produce action events. They do so when the user indicates somehow that the control should perform an action. For example, when the user clicks a button, an action event is generated. By implementing the action() method, you can react to user actions on controls without worrying about the low-level events, such as key presses and mouse clicks, that caused the action.

A Note about the action() Method: Action events are high-level events. They're caused by one or more low-level events such as key and mouse presses. For this reason, it's OK to return true to stop action events from travelling up the component hierarchy after you've handled them -- the platform-specific code has already handled the key or mouse events that triggered the action, so it doesn't need to see the action event.

Tutaj aplet wykorzystujący metodę action:

Kod tego apletu znajduje się tutaj.


Gdańsk 03.05.1998