سؤال

In the catch block I want to display a error message to textArea to display the error happening.

هل كانت مفيدة؟

المحلول

Since you are not on the EDT, you can use SwingUtilities#invokeLater to safely perform your action on the EDT.

نصائح أخرى

A catch block does not limit the methods you can call in any way : it is only different from the try block above it in that it is not, as is, in a exception handling scope.

Thus, you can

1) enclose the call to Any exception throwing gui elements, in the catch block, inside another try/catch

Or simpler

2) Simply use a component like JoptionPane which will safely launch an exception-less dialog box.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top