Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top