• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JOptionPane and JDialog

 
Anuji Philip
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't undrstand how JDialog's show method could invoke JOptionPane.
eg.
if(jdlg.show()==JOptionPane.CANCEL_OPTION)
throw new Exception();
where this two classes are not directly related
in heirarchy.
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I don't understand your question. Can you post a bit more code and can you describe a bit clearer, what happens.
Thanks
Rene
 
Anuji Philip
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic