Here is a little snippet you can add to a method to ensure it executes in the the GUI thread. It relies on isEventDispatchThread()
.
public void updateGUI(final Status status) {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
updateGUI(status);
}
});
return;
}
//Now edit your gui objects
...
}