I have a main program, in which GUI is based on swing and depending on one of four states the GUI elements have different parameters.
public class Frame extends JFrame implements Runnable {
Status status = 1;
...
@Override
public void run() {
switch (status) {
case 1:
...
case 2:
...
}
public void updateGUI(Status status) {
this.status = status;
SwingUtilities.invokeLater(this);
}
And if I want to refresh the GUI invokes only updateGUI with appropriate parameter, and everything is fine. But the program also creates an additional thread, which after processing the relevant data should change the GUI main program. Unfortunately I can not in this thread call the method updateGUI (..).
I know that I can use invokeLater or SwingWorker to refresh but there are more than 10 elements so I would rather use the method udpateGUI ().
I will be grateful for any hint.