Here you can find the source of showExceptionMessage(Component parent, Throwable t)
Parameter | Description |
---|---|
parent | Parent component of the message bos. |
t | Throwable with the exception details. |
public static void showExceptionMessage(Component parent, Throwable t)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class Main { /**/*from w w w. ja v a2s .com*/ * Shows a message box with exception details. * * @param parent Parent component of the message bos. * @param t Throwable with the exception details. */ public static void showExceptionMessage(Component parent, Throwable t) { StringBuilder sb = new StringBuilder(); sb.append("An unexpected error occured during the execution of the requested task.\n"); sb.append("The error data can be seen below:\n\n"); sb.append(t.getLocalizedMessage()); sb.append(t.toString()).append("\n"); sb.append("Stack Trace:\n"); for (StackTraceElement e : t.getStackTrace()) { sb.append(e.toString()).append("\n"); } JTextArea tArea = new JTextArea(20, 50); tArea.setText(sb.toString()); JScrollPane sp = new JScrollPane(tArea); JOptionPane.showMessageDialog(parent, sp, "ERROR", JOptionPane.ERROR_MESSAGE); } }