I have several classes in my program, but for now we only have to worry about two of them: GUI and Logics.
The GUI class delegates to the Logics class:
Logics logics = new Logics();
This is because I want the GUI class to call methods I have in the Logics class.
But now I also want a method in GUI to be called from the Logics class. Specifically I want the Logics to be able to make a pop-up box in the GUI class (JDialog) visible when some certain condition (that is checked in the Logics class) is fulfilled.
How do I go about doing this? I can't delegate from Logics to GUI, because then I will get an overflow (delegating back and forth into infinity).
Does anybody have any suggestions? :)
-Thanks
Perhaps the Logics class could be given a service for showing dialogs. The GUI class could implement an Interface called DialogService (or whatever) that defines the methods for showing your dialogs. You could then call:
Logics logics = new Logics(this);
without the need for the Logics class to have access to the GUI class directly.