title: Printing stack trace in JOptionPane
body: <p>My question:
  How can i put the text e.printStackTrace prints into a JOptionPane window</p>
  <p>My code is currently as follows:<br />
  excuse the poor formatting :P</p>
  <pre><code>try {
    //SOME CODE
  } catch (Exception e) {
    e.printStackTrace();
    JOptionPane.showMessageDialog(null,
       &quot;An unexpected error has occurred:\n&quot; + e.getMessage() + '\n' + Thread.currentThread().getStackTrace() +  &quot;\nPlease send this error to .&quot; + email + &quot;\nThanks for your help.&quot;,
       &quot;Error&quot;, JOptionPane.ERROR_MESSAGE);
  }
  </code></pre>
  <p>this both prints the stack trace in the command line interface(i am using terminal) and it creates a JOptionPane but NOT with the same info as e.printStackTrace(). when running my program from a jar file, the command line interface won't be visible so the user will only get the JOptionPane window which doesnt have all of the info i need to succesfully identify the problem</p>
  <p>Thanks in advance :)</p>