Here you can find the source of showException(Component c, String message, Throwable t)
Parameter | Description |
---|---|
c | The parent component of the message popup |
message | The message to display on the popup |
t | The exception to display on the popup |
public static void showException(Component c, String message, Throwable t)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.awt.*; import javax.swing.*; public class Main { /**//from w ww . ja v a 2s .c o m * Utility method to display a popup with the provided Throwable * @param c The parent component of the message popup * @param t The exception to display on the popup */ public static void showException(Component c, Throwable t) { showException(c, t.getMessage(), t); } /** * Utility method to display a popup with the provided message ant Throwable * @param c The parent component of the message popup * @param message The message to display on the popup * @param t The exception to display on the popup */ public static void showException(Component c, String message, Throwable t) { if (t == null) { t = new Exception("Unknown Exception"); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(baos)); if (message == null) { message = t.getClass().getName(); } String stackTrace = baos.toString(); message += System.getProperty("line.separator") + stackTrace; JOptionPane.showMessageDialog(c, message, "Error Message", JOptionPane.ERROR_MESSAGE); } }