Listing 6. WindowBar Widget

import java.awt.event.* ;
import java.awt.* ;
import java.net.* ;
public class  WindowBar extends Panel implements
   ActionListener
   {
   public WindowBar() {
      super() ;
      _closer = new Button(
      "Collapse" ) ;
      _closer.addActionListener( this );
      //setLayout( new BorderLayout() );
      //add( "East", _closer );
      Panel p = new Panel() ;
      p.add( _closer ) ;
      add( p ) ;
   }
   public void addCollapseListener(
      PaneSwitchListener l )
      {
      _collapseListener =
         MyMulticaster.add(
         _collapseListener, l ) ;
   }
   public void actionPerformed( ActionEvent e )
      {
      if ( _collapseListener == null )
         return ;
      if ( _collapsed ) {
         _collapseListener.restore(
          new PaneSwitchEvent( this,
          PaneSwitchEvent.RESTORE ));
         _closer.setLabel(
          "Collapse" ) ;
      } else {
         _collapseListener.collapse(
          new PaneSwitchEvent( this,
          PaneSwitchEvent.COLLAPSE ));
         _closer.setLabel(
          "restore" ) ;
      }
      _collapsed = !_collapsed ;
   }
   private boolean _collapsed = false ;
   private PaneSwitchListener _collapseListener
      = null ;
   private Button _closer ;
}