Reputation: 369
I want to giving an alert when there is an exception, like in code:
try
{
//the code here
}
catch(Exception e)
{
//show an alert dialog here
}
An example or a code snippet is what I need.
Upvotes: 7
Views: 39869
Reputation: 726
try this:
JOptionPane.showMessageDialog(null, "My Goodness, this is so concise");
If you statically import JOptionPane.showMessageDialog this further reduces to
showMessageDialog(null, "This language just gets better and better!");
Upvotes: 12
Reputation: 16067
You can use JOptionPane.showMessageDialog
with WARNING_MESSAGE
:
JOptionPane.showMessageDialog(yourFrame,
"WARNING.",
"Warning",
JOptionPane.WARNING_MESSAGE);
More infos about how to make dialogs here.
Upvotes: 31