<<< Runtime Events | Index | Tool Tips >>> |
ActionListener interface specifies the
actionPerformed( ActionEvent evt );
method. The implementation can execute any statements in response to the event.
The actionPerformed() is invoked when the user
clicks a button
chooses a menu item
Note: When more than one component is added to the JFrame, it is necessary to find out which component is the source of the event:
/** * Handles user clicks */ public void actionPerformed( ActionEvent event ) { Object obj = event.getSource(); if ( obj == mButton ) { mButton.setText( "Click!" ); } }
<<< Runtime Events | Index | Tool Tips >>> |