Example usage for javax.swing JOptionPane showMessageDialog

List of usage examples for javax.swing JOptionPane showMessageDialog

Introduction

In this page you can find the example usage for javax.swing JOptionPane showMessageDialog.

Prototype

public static void showMessageDialog(Component parentComponent, Object message, String title, int messageType)
        throws HeadlessException 

Source Link

Document

Brings up a dialog that displays a message using a default icon determined by the messageType parameter.

Usage

From source file:Main.java

public static void error(Component parent, String message, String title) {
    JOptionPane.showMessageDialog(parent, message, title, JOptionPane.ERROR_MESSAGE);
}

From source file:Main.java

public static void showMessage(String msg) {
    JOptionPane.showMessageDialog(null, msg, "Information", JOptionPane.INFORMATION_MESSAGE);
}

From source file:Main.java

/**
 * Displays a {@link JOptionPane} as a warning message.
 *
 * @param title The title of the dialog.
 * @param message The message inside the dialog.
 *//*from w w  w  .j  a v  a2s .c  om*/
public static void showWarningMessage(String title, String message) {
    JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE);
}

From source file:Main.java

/**
 * Displays an error-message.//  ww  w  .j  a v  a2 s.c o  m
 * 
 * @param parent the parent <code>Component</code>
 * @param message the message to display
 */
public static void displayError(Component parent, String message) {
    JOptionPane.showMessageDialog(parent, message, null, JOptionPane.ERROR_MESSAGE);
}

From source file:Main.java

/**
 * Displays a {@link JOptionPane} as an information message.
 *
 * @param title The title of the dialog.
 * @param message The message inside the dialog.
 *///  w ww  .jav  a 2  s  .c o m
public static void showInformationMessage(String title, String message) {
    JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE);
}

From source file:Main.java

public static void showMessage(String message) {
    JOptionPane.showMessageDialog(null, message, "Warning", JOptionPane.WARNING_MESSAGE);
}

From source file:Main.java

public static void showInfo(Component parent, String message) {
    Component cmp = new JScrollPane(new JTextArea(message));
    cmp.setPreferredSize(new Dimension(400, 400));
    JOptionPane.showMessageDialog(parent, cmp, "Information", JOptionPane.INFORMATION_MESSAGE);
}

From source file:Main.java

/**
 * Shows a warning message dialog.//from   w w w. j a v a  2 s.com
 * 
 * @param c
 *            determines the Frame in which the dialog is displayed.
 * @param msg
 *            the message to display.
 */
public static void showWarningDialog(Component c, String msg) {
    JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(c), msg,
            UIManager.getString("OptionPane.warningDialogTitle"), JOptionPane.WARNING_MESSAGE);
}

From source file:Main.java

public static void showErrorMessage(Component parentComponent, String mensagem, Throwable t) {
    String errorMessage = t.toString();
    JOptionPane.showMessageDialog(parentComponent, mensagem + "\n" + errorMessage, "Erro",
            JOptionPane.ERROR_MESSAGE);
}

From source file:Main.java

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

    runInSwingThread(new Runnable() {
        @Override/*from w w w .  j av  a  2  s  .  c o m*/
        public void run() {
            //noinspection MagicConstant
            JOptionPane.showMessageDialog(parent, message, title, messageType);
        }
    });
}