/*
 * [TestButton.java]
 *
 * Summary: Demonstrate use of java.awt.Button.
 *
 * Copyright: (c) 2006-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.8+
 *
 * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.0 2006-03-02
 */
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
    {
    // ---- 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( 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 WindowClosing
            } // end anonymous class
        );// end addWindowListener line
        frame.validate();
        frame.setVisible( true );
        } // end main
    }