


You can use the ActionEvent-defined constants SHIFT_MASK, CTRL_MASK, META_MASK, and ALT_MASK to determine which keys were pressed. Most objects that can fire action events support a method called setActionCommand that lets you set this string.Returns an integer representing the modifier keys the user was pressing when the action event occurred. MethodCalled just after the user performs an action.Returns the string associated with this action. The Action Listener APIBecause ActionListener has only one method, it has no corresponding adapter class. The other example described in that section,MultiListener.java, has two action sources and two action listeners, with one listener listening to both sources and the other listening to just one. You can find the entire program inBeeper.java.
Komplete Action Strings How To Listen For
The listener uses the getActionCommand method to determine which radio button fired the event.Shows how to listen for action events on menu items.An applet that registers an action listener on a text field.Loads an image in an action listener. Also registers the same action listener on two different buttons.Registers the same action listener on five radio buttons. ExampleThis section and Introduction to Event ListenersContains one button with one action listener that beeps when you click the button.Registers two different action listeners on one button.
