I'm trying to program an swing application and learn something about the mvc pattern. Also I want to keep my Swing Code clean, so I split up my GUI in different classes. A part of this class structure looks like this:
//all classes extending BasicGuiElement
-EntireContentElement has:
---ControlElement has:
------MainMenuElement
MainMenuElement contains the MainMenuBar, the Menu's and the MenuItems. Now, different MenuItems need different ActionListeners.
And here is my Problem: Where should this ActionListener's come from? Should i create the EntireControlElement in the View, to which i pass an HashMap and also pass this map through all the elements to MainMenuElement? And if i have many classes who all needs a bunch of action listeners, i would pass a list of listener maps? That would be really ugly code, would'nt it?
Another solution would be to pass the Model as the ModelInterface to the View, and call model methods from the action listeners, which would be created in the view classes... would that be a nicer approach?
Thank you!