Here you can find the source of displayError(Throwable e)
public static void displayError(Throwable e)
//package com.java2s; //License from project: Apache License import java.awt.EventQueue; import java.awt.KeyboardFocusManager; import java.awt.Window; import javax.swing.JOptionPane; public class Main { public static void displayError(Throwable e) { displayMessageBox(e == null ? "Error performing operation." : e.getMessage(), JOptionPane.ERROR_MESSAGE, false);//from w w w .j a va 2 s . co m } public static void displayError(String strMsg) { displayMessageBox(strMsg, JOptionPane.ERROR_MESSAGE, false); } public static void displayMessageBox(String strMsg, final int iType, boolean bWrapText) { final String strWrappedMsg = bWrapText ? wrapText(strMsg) : strMsg; Runnable logMsgBox = new Runnable() { public void run() { JOptionPane.showMessageDialog(getWindow(), strWrappedMsg, "", iType); } }; if (EventQueue.isDispatchThread()) { logMsgBox.run(); } else { try { EventQueue.invokeAndWait(logMsgBox); } catch (Throwable t) { t.printStackTrace(); } } } public static String wrapText(String strText) { return wrapText(strText, 60); } public static String wrapText(String strText, int iLineLen) { StringBuilder sb = new StringBuilder(); while (strText != null) { if (strText.length() > iLineLen) { sb.append(strText.substring(0, 60)).append("\n"); strText = strText.substring(60); } else { sb.append(strText); strText = null; } } return sb.toString(); } public static Window getWindow() { return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); } public static Window getFocusedWindow() { return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); } }