So as far as I understood, all the swing components should be created, modified and queried only from the EDT.
So if I happen to press a JButton
\"submit\" let\
Any action triggered from Swing will run on the EDT. So the code in your actionPerformed
method will already be executed on the EDT, without any special handling by you.
To start a long-running task, like sending data to a server, use a SwingWorker or a Callable
and an ExecutorService
.
I prefer using a SwingWorker
when implementing a Swing UI, as has it a useful API for publishing updates and makes the callbacks when the task is done automatically happen on the EDT.