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

有帮助吗?

解决方案

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()); }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top