Skip to content
Advertisement

How to open warning/information/error dialog in Swing?

How to open warning/information/error dialog in Swing?

I need standard error dialog with “Ok” button and “red cross” image. I.e. analog of org.eclipse.jface.dialogs.MessageDialog.openError()

Advertisement

Answer

See How to Make Dialogs.

You can use:

JOptionPane.showMessageDialog(frame, "Eggs are not supposed to be green.");

And you can also change the symbol to an error message or an warning. E.g see JOptionPane Features.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement