Complete Program
For such a complicated relationship diagram,
this is a short program.
import java.awt.*;
import java.awt.event.*;
public class buttonQuitter extends Frame implements ActionListener
{
Button bQuit = new Button("Click here to Exit"); // Construct a Button.
buttonQuitter() // constructor for buttonQuitter
{
setLayout( new FlowLayout() ); // Choose the layout manager.
bQuit.addActionListener( this ); // Register the buttonQuitter object
// as the listener for its Button.
add( bQuit ); // Add the button to the buttonQuitter object.
}
public void actionPerformed( ActionEvent evt)
{
System.exit( 0 );
}
public static void main ( String[] args )
{
buttonQuitter bQuit = new buttonQuitter();
bQuit.setSize( 200, 150 );
bQuit.setVisible( true );
}
}
|
The program can be copied to NotePad, compiled and run in the usual way.
|