質問

is

function(Component C){ Box.add(C);validate();}

Thread-safe or does it need to be called in an EventsDispatcherThread?

if they need to be called in the Events Dispatcher Thread, do both Box.add as well as validate() need to be inside the EDT or only box.add is?

役に立ちましたか?

解決

You should run your code in the event dispatch thread.

As you can read in Oracle documentation: http://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html

You can use Swing classes outside EDT only if they are marked as thread safe in the documentation.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top