How can I update a GUI

In the code below, how is I've updated the generated random number GUI? I can't use a static method, because I may need more than one instance of the user interface and each instance must have its own unique output displayed. I can't combine the two class together because I want to serialize the controller, but NOT the GUI.
public class Controller{
     public void makeNums(){
          // creates random numbers at random times
     }
}

public class Gui{
     private Controller control;
     public Gui(Controller control){
          this.control = control;
          openGui();                  // this method creates all the components of the GUI
          control.makeNums();
     }
}
How the controller can change the GUI after the random number was generated?

It is pretty trivial:

public class Controller{
     private Gui gui;
     public void makeNums(){
          // creates random numbers at random times
     }
     public void setGui(Gui gui) {
          this.gui = gui;
     }
}

public class Gui{
     private Controller control;
     public Gui(Controller control){
          this.control = control;
          openGui();                  // this method creates all the components of the GUI
          control.makeNums();
          control.setGui(this);
     }
}

Tags: Java

Similar Questions

Maybe you are looking for