I am working on a gui system using swing and I am trying to follow the Model-View-Controller model. I am sort of confused a stuck when it comes to implementing my event system so that the view can communicate with the controller when things occur on the gui.
My gui is dynamic so that I have a side panel that contains other JPanels on it. One of them happen to be a LoginPanel which throws a LoginEvent when someone tries to login. Since I want my SidePanel to be dynamic, the SidePanel doesn't know that the LoginPanel exists, it is just drawing what it is told to draw.
When I start the program, the model and view are started separately and the controller gets passed an instance of both the model and the view.
Using the MVC system, how do I tell the LoginPanel that a controller (that implements LoginEventListener) wants to listen to it when the LoginPanel is dynamic on my gui and doesn't exist at all times?