// Typical local class, one that implements
// the ActionListener interface.

public void init()
   {
   /* ... */

   // define a class right in the middle of the init method
   class MyListener implements ActionListener
      {

      // method of local class MyListener
      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.
         Outer.this.insultText.setText( Outer.generateInsult() );
         }

      };

   insultButton.addActionListener( new MyListener() );

   /* ... */

   }