Java JOptionPane Message showMessage(final Window parent, final String message, final String title, final int messageType)

Here you can find the source of showMessage(final Window parent, final String message, final String title, final int messageType)

Description

show Message

License

Open Source License

Declaration

public static void showMessage(final Window parent, final String message, final String title,
            final int messageType) 

Method Source Code


//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);
            }
        }
    }
}

Related

  1. showMessage(final Component rootComponent, final String message, final String title)
  2. showMessage(final String message)
  3. showMessage(final String message)
  4. showMessage(final String msg, Component parent)
  5. showMessage(final Window aParent, final String aMessage)
  6. showMessage(Object message)
  7. showMessage(String message)
  8. showMessage(String message)
  9. showMessage(String message, String title)