Here you can find the source of displayErrorMessage(final Throwable throwable, final Component parentComponent)
public static void displayErrorMessage(final Throwable throwable, final Component parentComponent)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.*; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static void displayErrorMessage(final Throwable throwable, final Component parentComponent) { StringWriter stackTrace = new StringWriter(); throwable.printStackTrace(new PrintWriter(stackTrace)); JTextArea textArea = new JTextArea(stackTrace.toString(), 25, 100); textArea.setEditable(false);/*from www .j a va 2 s . co m*/ textArea.setTabSize(4); textArea.setForeground(Color.RED); textArea.setFont(textArea.getFont().deriveFont(12f)); JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(parentComponent), new JScrollPane(textArea), "Unhandled Error", JOptionPane.PLAIN_MESSAGE, null); } }