Java JOptionPane Error errMsg(final Component owner, final String msg, final Throwable e)

Here you can find the source of errMsg(final Component owner, final String msg, final Throwable e)

Description

show an error message and print a stack trace to the console if in development mode (DEV_MODE = true)

License

Open Source License

Parameter

Parameter Description
owner the owner of the message, or null
msg the message to display, or null
e the exception object describing the error, or null

Declaration

public static void errMsg(final Component owner, final String msg, final Throwable e) 

Method Source Code


//package com.java2s;
/*//from  w  w  w  . j  ava2s  .c  o m
 * SimplyHTML, a word processor based on Java, HTML and CSS
 * Copyright (C) 2002 Ulrich Hilger
 *
 * This program 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

import java.awt.Component;

import javax.swing.JOptionPane;

public class Main {
    private static final String ERR_TITLE = "Error";

    /**
     * show an error message and print a stack trace to the console if
     * in development mode (DEV_MODE = true)
     *
     * @param owner the owner of the message, or null
     * @param msg the message to display, or null
     * @param e the exception object describing the error, or null
     */
    public static void errMsg(final Component owner, final String msg, final Throwable e) {
        if (e != null) {
            e.printStackTrace();
        }
        if (msg != null) {
            JOptionPane.showMessageDialog(owner, msg, ERR_TITLE, JOptionPane.ERROR_MESSAGE);
        }
    }
}

Related

  1. displayErrorMessage(Component parentComponent, String message, String windowTitle)
  2. displayErrorMessage(final Throwable throwable, final Component parentComponent)
  3. displayErrorMessage(String msg, Throwable t)
  4. displayErrors(Component parent, List errors)
  5. errMsg(Component owner, String msg, Exception e)
  6. errMsg(final String msg)
  7. errMsg(String msg)
  8. error(Component comp, String title, String message, Object[] args)
  9. error(Component parent, Exception e)