FileDocCategorySizeDatePackage
Colours2.javaAPI DocExample1293Sun Mar 15 16:28:50 GMT 1998None

Colours2

public class Colours2 extends Frame

Fields Summary
Constructors Summary
public Colours2()

  setTitle( "Colours2" );
      setSize ( 200, 200 );
      setLayout( new FlowLayout() );
      Button red = new Button( "Red" );
      red.setBackground( Color.white );
      red.setForeground( Color.black );  
      Button blue = new Button( "Blue" );
      blue.setBackground( Color.white );
      blue.setForeground( Color.black );  
      add( red );
      add( blue );
      
      red.addActionListener( new ActionListener() {
         public void actionPerformed( ActionEvent e )
         {  setBackground( Color.red );
            repaint();
         }
      });
      
      blue.addActionListener( new ActionListener() {
         public void actionPerformed( ActionEvent e )
         {  setBackground( Color.blue );
            repaint();
         }
      });
         
      addWindowListener( new WindowAdapter() {
         public void windowClosing( WindowEvent e )
         {  System.exit(0);
         }
      }); 
      
      setVisible( true );
   
Methods Summary
public static voidmain(java.lang.String[] args)

  new Colours2();