Here you can find the source of showMessage(final Window parent, final String message, final String title, final int messageType)
public static void showMessage(final Window parent, final String message, final String title, final int messageType)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.*; import java.lang.reflect.InvocationTargetException; public class Main { public static void showMessage(final Window parent, final String message, final String title, final int messageType) { runInSwingThread(new Runnable() { @Override// w w w. j av a2s. c o m public void run() { //noinspection MagicConstant JOptionPane.showMessageDialog(parent, message, title, messageType); } }); } public static void runInSwingThread(final Runnable runnable) { if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { try { SwingUtilities.invokeAndWait(runnable); } catch (final InvocationTargetException | InterruptedException e) { throw new RuntimeException(e); } } } }