Java JOptionPane Message excMsg(String msg, Exception ex)

Here you can find the source of excMsg(String msg, Exception ex)

Description

Exception message dialog.

License

Open Source License

Parameter

Parameter Description
msg a parameter
ex a parameter

Declaration

public static void excMsg(String msg, Exception ex) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

public class Main {
    public static final String LS = System.getProperty("line.separator");

    /**/* w ww  . j  a v  a  2s .  c om*/
     * Exception message dialog. Displays message plus the exception and
     * exception message.
     * 
     * @param msg
     * @param ex
     */
    public static void excMsg(String msg, Exception ex) {
        final String fullMsg = msg += LS + "Exception: " + ex + LS + ex.getMessage();
        // Show it in a message box
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(null, fullMsg, "Error", JOptionPane.ERROR_MESSAGE);
                System.out.println(fullMsg);
            }
        });
    }

    /**
     * Exception message dialog. Displays message plus the error and error
     * message.
     * 
     * @param msg
     * @param ex
     */
    public static void excMsg(String msg, Error ex) {
        final String fullMsg = msg += LS + "Exception: " + ex + LS + ex.getMessage();
        // Show it in a message box
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(null, fullMsg, "Error", JOptionPane.ERROR_MESSAGE);
            }
        });
    }
}

Related

  1. displayMessage(Component parent, String string, String title)
  2. displayMessage(Component parentComponent, String message, String windowTitle, int messageType)
  3. displayMessage(String message)
  4. displayMessagePane(String desc, String title)
  5. excMsg(String msg, Exception ex)
  6. excMsg(String msg, Throwable t)
  7. exibeMsg(String msg, int tipoMsg)
  8. getIconForType(int messageType)
  9. getInput(String msg, String defaultInput)