show Exception Message via JOptionPane - Java Swing

Java examples for Swing:JOptionPane

Description

show Exception Message via JOptionPane

Demo Code


//package com.java2s;
import java.awt.Component;
import javax.swing.JOptionPane;

public class Main {
    private static Component mainComponent = null;

    public static void showExceptionMessage(Exception e) {
        String msg = "An exception has occurred.\n\n"
                + e.toString()//from www  .j a  v a2s.  co m
                + "\n\nIf problems persist, please contact your local administrator.";
        // log exception
        e.printStackTrace(System.out);

        JOptionPane.showMessageDialog(mainComponent, msg, "Exception",
                JOptionPane.ERROR_MESSAGE);
    }
}

Related Tutorials