// The following code is only necessary if you want
// any keystroke while the Dismiss button has focus
// to simulate clicking the Dismiss button.
dismissButton.addKeyListener
( new KeyAdapter()
     {

     /**
     * Handle Dismiss button getting a function key,
     * treat like a dismiss Button click
     *
     * @param e event giving details
     */
     public void keyPressed ( KeyEvent e )
        {
        dismiss();
        } // end keyPressed

     /**
     * Handle Dismiss button getting an ordinary keystroke,
     * treat like a dismiss Button click
     *
     * @param e event giving details
     */
     public void keyTyped ( KeyEvent e )
        {
        dismiss();
        } // end keyTyped } // end anonymous class ); // end addKeyListener line

     ...

     /**
     * Shutdown the Dialog box
     */
     void dismiss()
        {
        // close the Dialog box
        this.setVisible( false );
        // tell AWT to discard all pointers to the Dialog box,
        // so that it and dependent objects can soon be garbage collected.
        this.dispose();
        } // end dismiss