Hi,
Is there a C# type MessageBox() in Java? That is a standard notification
dialog box to which some text and buttons like 'OK', 'OK and Cancel', 'Yes
or No', etc. can be displayed quickly.
In C# you would do this:
DialogResult res = MessageBox.Show(text, title,
MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
I've been trawling through the API and can't find such a thing.
Thanks,
MS
Thomas Kellerer - 21 Feb 2005 22:23 GMT
MS wrote on 21.02.2005 23:17:
> Hi,
>
[quoted text clipped - 8 lines]
>
> I've been trawling through the API and can't find such a thing.
Seems you overlooked this one :)
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JOptionPane.html
especially:
<http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JOptionPane.html#showConfirm
Dialog(java.awt.Component,%20java.lang.Object,%20java.lang.String,%20int)>
Your example would be:
int choice = JOptionPane.showConfirmDialog(parent,
"The message",
"The title",
JOptionPane.YES_NO_OPTION);
if (choice == JOptionPane.YES_OPTION)
{
...
}
Thomas
MS - 21 Feb 2005 23:11 GMT
> int choice = JOptionPane.showConfirmDialog(parent,
> "The message",
> "The title",
> JOptionPane.YES_NO_OPTION);
> if (choice == JOptionPane.YES_OPTION)
Looks like just the thing. Many thanks.
MS - 22 Feb 2005 19:52 GMT
MS emailed this:
>> int choice = JOptionPane.showConfirmDialog(parent,
>> "The message",
[quoted text clipped - 3 lines]
>
> Looks like just the thing. Many thanks.
It is -- useful class.
Thanks again.