So i have this code, which opens a JOptionPane
with information about the exception:
String fileName=e.getStackTrace()[0].getFileName();
String methodName=e.getStackTrace()[0].getMethodName();
String line=String.valueOf(e.getStackTrace()[0].getLineNumber());
JOptionPane.showMessageDialog(null, new JLabel("There was an unexpected "+e+" at file: "+fileName+" in method: "+methodName+" in line: "+line));
The only thing i am not happy with is the fact that its all the same color, so i thought why not change the color of the Strings regarding the exception to red. So i googled a bit and found several similar question on SO, and also tried what they suggested there with html-tags and such, but i was not successful. Is there any working way to color the text? Currently it looks like this with html tags
The entire string needs to be enclosed within the HTML tags. For more information, see How to Use HTML in Swing Components.