// File: Colours1.java
// T Balls : March 1998
// Capture event from a Button
// and change background colour
import java.awt.*;
import java.awt.event.*;
public class Colours1 extends Frame
{ public static void main( String[] args )
{ new Colours1();
}
public Colours1()
{ setTitle( "Colours1" );
setSize ( 200, 200 );
Button red = new Button( "Red" );
add( "North", red );
red.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e )
{ setBackground( Color.red );
repaint();
}
});
setVisible( true );
}
}
|