Showing an Alert Dialog in Java Swing

java, swing

Solution

You can use `JOptionPane.showMessageDialog` with `WARNING_MESSAGE` :

JOptionPane.showMessageDialog(yourFrame,
    "WARNING.",
    "Warning",
    JOptionPane.WARNING_MESSAGE);

More infos about how to make dialogs here.

Problem

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.

Original source