I would like to apply the MVC design to my Java application using Swing in a meaningful way. Therefore my question is, how the controllers would be structured in Java Swing?
I have two options in mind:
- Every Component Listener is an own class, as part of the controller package
- Every Component Listener is an anonymous class inside the view package which delegates its call to a class with controller methods. Is both possible?
Yes both is possible but I will prefer to write Single class which implements all actionListioner and assign that same to all component in your app. This way you can track all actions in your app at single point. Also this way you can make your view distinguish from controller.