Buttons and ActionListeners Specify interaction by attaching Listeners to GUI objects JButton b = new JButton( do it! ); b.addActionListener(new DoIt()); … private class DoIt implements ActionListener { public void actionPerformed( ActionEvent e) { // whatever }
{}