Have your thought about using a JOptionPane?  I think it's better if you
only want a warning message to show.  Something like this has all the
buttons and closing methods built in:

JOptionPane.showConfirmDialog(ParentFrame, warnMessage, "Warning",
JOptionPane.YES_NO_OPTION );

There are also showErrorDialog, showMessageDialog, etc.  (See the API)
With these you can also specify your own button set and default button
choice, and the method returns the value of the chosen button.

Otherwise, with JDialog, you can add an actionlistener to a button and
then call yourDialog.hide() in the actionPerformed() method to hide your
dialog box.

For example, for JButton jbCancel, with message "Cancel":

private void actionPerformed(ActionEvent e) {
        if (e.getSource() == jbCancel) 
                this.hide();
}

I use hide, because I want to retain the settings that the user has
entered into the dialog.  If you just want to show a message then
destroy the dialog, you could set the dialog to null when the button is
pressed, and it will be garbage collected, I think.  You can also add a
WindowListener if there are any actions you want to carry out when the
user clicks the x in the upper right corner.  Again, here I use "hide"
to ensure the dialog isn't trashed:

addWindowListener(new WindowAdapter() {
       public void windowClosing(WindowEvent e) {
                hide();
            }
});


Good luck,

Chris

==========================================================================To 
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to