示例#1
0
  /**
   * Display an exception in a nice user-oriented way. Instead of displaying the whole stack trace,
   * just display the exception message and a button for displaying the whole stack trace.
   */
  public static void showException(Component parent, Exception e, String info) {
    Object[] message = new Object[1];
    String string;

    if (info != null) {
      string = info + "\n" + e.getMessage();
    } else {
      string = e.getMessage();
    }

    message[0] = ellipsis(string, 400);

    Object[] options = {"Dismiss", "Display Stack Trace"};

    // Show the MODAL dialog
    int selected =
        JOptionPane.showOptionDialog(
            parent,
            message,
            "Exception Caught",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE,
            null,
            options,
            options[0]);

    if (selected == 1) {
      showStackTrace(parent, e, info);
    }
  }
示例#2
0
 /**
  * Display a stack trace dialog. Eventually, the dialog should be able to email us a bug report.
  */
 public static void showStackTrace(Component parent, Exception e) {
   showStackTrace(parent, e, null);
 }
 /** Show an error in a dialog box with stack trace. */
 public void showError(String op, Exception e) {
   GUIUtilities.showStackTrace(
       getAppContext().makeComponent(), e, "Please submit a bug report.\n\n" + op);
 }