public static void showExceptions(Component parent, Throwable theExc) {

        Throwable next = null;

        do {
            String className = theExc.getClass().getName();
            String message = className;

            if (theExc instanceof SQLException) {
                SQLException sexc = (SQLException)theExc;
                message += "; code=" + sexc.getErrorCode();
                next = sexc.getNextException();
            } else {
                next = theExc.getCause();   // Comment out if < JDK 1.4
			}

            String[] choices = next != null ? choicesMore : choicesNoMore;

            /* Show the Dialog! */
            int response = JOptionPane.showOptionDialog(
                parent,
                message,
                className,                             // title
                JOptionPane.YES_NO_CANCEL_OPTION,      // icontType
                JOptionPane.ERROR_MESSAGE,             // messageType
                null,                                  // icon
                choices,                               // options
                choices[0]                             // default
                );

            if (response == 0)          // "OK"
                return;
            if (response == 1) {        // "Details"
                // show ANOTHER JDialog with a JTextArea of printStackTrace();
                if (detailsDialog == null) // first time, lazy creation
                    detailsDialog = new DetailsDialog((JFrame)parent);
                detailsDialog.showStackTrace(theExc);
            }
            // else resp = 2, "Next", let it fall through:

            theExc = next;

        } while (next != null);
    }