Question

I am working on Java program having several components. What I am trying to achieve is, that any Exception be displayed in the JTextArea, and not in the console. The code below doesn't work. What can I do?

catch ( MalformedURLException e) { textArea.append(e); }

Thank you

Was it helpful?

Solution

The JTextArea does not support the append() method. You could try this if you just need to display the error:

catch ( MalformedURLException e) { textArea.setText(e.toString()); }

You could try this if you need to append the message:

catch ( MalformedURLException e) { textArea.setText(textArea.getText()+e.toString()); }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top