package com.mindprod.example;
import java.awt.Button;
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import static java.lang.System.*;
/**
* Demonstrate use of java.awt.Button.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2006-03-02
* @since 2006-03-02
*/
public final class TestButton
{
/**
* Debugging harness for a Frame
*
* @param args command line arguments are ignored.
*/
public static void main( String args[] )
{
final Frame frame = new Frame();
Button button = new Button( "alert" );
button.setBackground( Color.BLACK );
button.setForeground( Color.YELLOW );
button.setFont( new Font( "Dialog", Font.BOLD, 15 ) );
button.setEnabled( true );
button.addActionListener( new ActionListener()
{
/**
* Invoked when a button pressed
*/
public void actionPerformed( ActionEvent e )
{
out.println( "button pressed" );
}
} );
frame.add( button );
frame.setSize( 100, 100 );
frame.addWindowListener( new WindowAdapter()
{
/**
* Handle request to shutdown.
* @param e event giving details of closing.
*/
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}
}
);// end addWindowListener line
frame.validate();
frame.setVisible( true );
}
}