Basic HTML version of Foils prepared March 26 1999

Foil 5 The ActionListener Interface

From Java Academy:Graphical User Interface NPAC Java Academy February--April 99 -- March 1999. by Nancy McCracken


To include a handler method for ActionEvents in your applet, you first add to your applet header that you are going to "implement" this interface: public class ButtonTest extends Applet implements ActionListener
This means that your applet must include a handler method called actionPerformed. Its argument is an ActionEvent, which has methods to give information about the event: public void actionPerformed ( ActionEvent event ) { if ( event.getSource ( ) == button1 ) { // code executed when button1 is pressed } . . . }



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Fri Mar 26 1999