I have a main program in which the GUI is based on swing and depending on one of the 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 update the GUI, it only calls updateGUI with the appropriate parameter, and everything is fine. But the program also creates an additional stream, which, after processing the corresponding data, should change the main GUI program. Unfortunately, I cannot call the updateGUI (..) method in this thread.
I know that I can use invokeLater or SwingWorker to update, but there are more than 10 elements, so I would rather use the udpateGUI () method.
I would be grateful for any hint.
source share