/*
 * [TestTextField.java]
 *
 * Summary: demonstrate the use of java.awt.TextField.
 *
 * Copyright: (c) 2009-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 2009-01-01 initial version
 */
package com.mindprod.example;

import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.TextField;
import java.awt.event.TextEvent;
import java.awt.event.TextListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import static java.lang.System.*;

/**
 * demonstrate the use of java.awt.TextField.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0 2009-01-01 initial version
 * @since 2009-01-01
 */
public final class TestTextField
    {
    /**
     * Debugging harness for a Frame
     *
     * @param args not used.
     */
    public static void main( String args[] )
        {
        final Frame frame = new Frame();
        final TextField textfield = new TextField( "this is a TEST" );
        textfield.setBackground( Color.BLACK );
        textfield.setForeground( Color.YELLOW );
        textfield.setFont( new Font( "Dialog", Font.BOLD, 15 ) );
        textfield.setEnabled( true );
        textfield.setEditable( true );
        textfield.addTextListener( new TextListener()
            {
            /**
             * Invoked when the value of the text has changed. The code written
             * for this method performs the operations that need to occur when
             * text changes.
             */
            public void textValueChanged( TextEvent e )
                {
                out.println( textfield.getText() );
                }
            } );
        frame.add( textfield );
        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
    }