/**
 * Sample #1: Create a frame with a quit button,
 * a push-me button, and an uneditable text field.
 * Hitting push-me adds an '*' to the text field.
 */
import javax.swing.*;
import java.awt.event.*;

public class Swing1
{
    public static void main( String [] args )
    {
        JFrame f = new JFrame( "Swing Test" );

        f.addWindowListener( new WindowAdapter( )
        {
            public void windowClosing( WindowEvent e )
            {
                System.exit( 0 );
            }
        } );

        JPanel p = new JPanel( );
        JButton qb = new JButton( "quit" );
        JButton pb = new JButton( "push me" );
        final JTextField tf = new JTextField( 20 );

        tf.setEditable( false );
        p.add( qb );
        p.add( pb );
        p.add( tf );

        f.setContentPane( p );
        f.setSize( 300, 100 );
        f.setVisible( true );

        qb.addActionListener( new ActionListener( )
        {
            public void actionPerformed( ActionEvent e )
            {
                System.exit( 0 );
            }
        } );
        pb.addActionListener( new ActionListener( )
        {
            public void actionPerformed( ActionEvent e )
            {
                tf.setText( tf.getText( ) + "*" );
            }
        } );
    }
}
