Here you can find the source of showErrorMsg(final Container parent, final String message)
public static void showErrorMsg(final Container parent, final String message) throws HeadlessException
//package com.java2s; //License from project: Apache License import java.awt.Container; import java.awt.HeadlessException; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; public class Main { public static void showErrorMsg(final Container parent, final String message) throws HeadlessException { SwingUtilities.invokeLater(new Runnable() { @Override//from w ww . j ava 2s . c om public void run() { JOptionPane.showMessageDialog(parent, message, UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.ERROR_MESSAGE); } }); } }