// Typical anonymous class, one that implements
// the ActionListener interface.
// We instantiate only one object of this class ever.
// This code would live typically in an Applet.init method

insultButton.addActionListener( new ActionListener()

   public void actionPerformed ( ActionEvent e )
      // insultText is a field of the outer class,
      // in which this anonymous class is embedded.
      // generateInsult is a method of the outer class.
      insultText.setText( generateInsult() );

   } );