ActionListener
Previous    Next    Home    Source Code    Package

Notes
  1. Now we want to perform some actions with the widgets. In this case, when the JButton is clicked, the string showing in the JComboBox is added to the JTextArea. You can selected a different string by "dropping" and "choosing" from the JComboBox.
  2. To activate any button or textfield, change the class definition to
       public class Prog4 extends Applet implements ActionListener {
    
    and, in init, add a listener to the button like this
       button.addActionListener(this);
    
    Finally, the following method must be implemented (or it does not compile)
       public void actionPerformed (ActionEvent evt) {
          ...
       }