Here you can find the source of showErrorDialog(JFrame parent, Exception ex)
public static void showErrorDialog(JFrame parent, Exception ex)
//package com.java2s; //License from project: Open Source License import java.awt.Dimension; import java.awt.Font; import java.io.PrintWriter; import java.io.StringWriter; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class Main { public static void showErrorDialog(JFrame parent, Exception ex) { JTextArea textArea = new JTextArea(); textArea.setFont(new Font("Sans-Serif", Font.PLAIN, 10)); textArea.setEditable(false);// w ww.j av a 2 s. c om StringWriter writer = new StringWriter(); ex.printStackTrace(new PrintWriter(writer)); textArea.setText(writer.toString()); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setPreferredSize(new Dimension(350, 150)); JOptionPane.showMessageDialog(parent, scrollPane, "An Error Has Occurred", JOptionPane.ERROR_MESSAGE); } }