Java JOptionPane Message showMessage(Component parent, String message, int messageType)

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

Description

Show a JOptionPane message dialog.

License

Open Source License

Parameter

Parameter Description
parent parent component
message the message string
messageType the message type as defined in <tt>JOptionPane</tt>

Declaration

public static void showMessage(Component parent, String message, int messageType) 

Method Source Code


//package com.java2s;
/*//from w  w  w.  j a v a  2s .  c  o  m
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the license, or (at your option) any later version.
*/

import javax.swing.*;
import java.awt.*;

public class Main {
    /**
     * The title for message boxes.
     */
    public static final String MESSAGE_TITLE = "jclasslib";

    /**
     * Show a <tt>JOptionPane</tt> message dialog.
     *
     * @param parent      parent component
     * @param message     the message string
     * @param messageType the message type as defined in <tt>JOptionPane</tt>
     */
    public static void showMessage(Component parent, String message, int messageType) {
        if (parent != null && !(parent instanceof Window)) {
            parent = SwingUtilities.getAncestorOfClass(Window.class, parent);
        }
        JOptionPane.showMessageDialog(parent, message, MESSAGE_TITLE, messageType, null);
    }
}

Related

  1. showLog(int type, String title, String message)
  2. showMessage(Component c, String message, String title)
  3. showMessage(Component c, String msg)
  4. showMessage(Component component, String message)
  5. showMessage(Component item, String title)
  6. showMessage(Component parent, String msg, String title, int flags)
  7. showMessage(Component parentComponent, String title, String message, int messageType)
  8. showMessage(final Component rootComponent, final String message, final String title)
  9. showMessage(final String message)