سؤال

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