package com.mindprod.example;

import com.mindprod.common11.FontFactory;

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;

/**
 * Demonstrate use of java.awt.Button
 * <p/>
 * composed with IntelliJ IDEA
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0, 2006-03-02
 */
public final class TestButton
    {
    // --------------------------- main() method ---------------------------

    // ---- PUBLIC METHODS ----

    /**
     * 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( FontFactory.build( "Dialog", Font.BOLD, 15 ) );
        button.setEnabled( true );
        button.addActionListener( new ActionListener()
        {
        /**
         * Invoked when a button pressed
         */
        public void actionPerformed( ActionEvent e )
            {
            System.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 WindowClosing
        }// end anonymous class
        );// end addWindowListener line
        frame.validate();
        frame.setVisible( true );
        }// end main
    }