Blanks filled In
public class buttonDemo extends Frame implements ActionListener
{
Button bChange = new Button("Click Me!"); // construct a Button
buttonDemo() // constructor for buttonDemo
{
setLayout( new FlowLayout() ); // choose the layout manager
add( bChange ); // add the button to the container
}
public void actionPerformed( ActionEvent evt)
{
. . . . . .
}
public static void main ( String[] args )
{
buttonDemo frm = new buttonDemo();
. . . . .
}
}
|
In this style of GUI programming,
one object (the buttonDemo object) is playing several roles:
it is the container object, and it is also the listener object.
However, implementing ActionListener is not enough.
The listener must still be registered with the Button.
|