/**
 * Sample #2: Same as #1, but add a mneumonic, and tooltips.
 */
import java.awt.event.*;
import javax.swing.*;

public class Swing2
{
    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.setMnemonic( 'q' );
        qb.setToolTipText( "press to quit" );
        pb.setMnemonic( 'a' );
        pb.setToolTipText( "press to add *" );

        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( ) + "*" );
            }
        } );
    }
}
