File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JOptionPane and JDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JOptionPane and JDialog" Watch "JOptionPane and JDialog" New topic

JOptionPane and JDialog

Anuji Philip
Ranch Hand

Joined: Feb 25, 2002
Posts: 46
I couldn't undrstand how JDialog's show method could invoke JOptionPane.
throw new Exception();
where this two classes are not directly related
in heirarchy.
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
I don't understand your question. Can you post a bit more code and can you describe a bit clearer, what happens.
Anuji Philip
Ranch Hand

Joined: Feb 25, 2002
Posts: 46
A sentence from javax.swing.JDialog API from sun ;
You can use this class to create a custom dialog, or invoke the many static methods in JOptionPane to create a variety of standard dialogs

I could not understand the meaning of that.
Kindly explain where this comes and how
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
JOptionPane provides a set of static methods to create dialogs that are often needed for user interaction: for example to notify the user of some ongoing or to retrieve input like a password or to ask for a decision (save or save not on exit e.g.).
JOptionPane probably uses JDialog internally though this is of no relevance if you are using JOptionPane.
Even if it seems that the static methods in JOptionPane create only some very common dialogs it is possible to create very special dialogs using these methods. This is the case because the methods take Object instances as arguments instead of, say, Strings to display a message. Thus, you can put a whole panel into a dialog created by JOptionPane. (see the API for JOptionPane for an introduction on the different argument types.)
I for my part have never used JDialog. JOptionPane always proved sufficient and _highly_ customizable enough.
I agree. Here's the link:
subject: JOptionPane and JDialog
It's not a secret anymore!