I wanted to try to make a sample traffic light program using paintComponent, but i'm a little confused on the MVC approach for it, 2 questions:
I've made it with a frame(view) engine(model) and a JButton(controller), which will turn the light on/off.
To me, the simplest way to have this done, is having my controller directly communicate to the view, by calling toggle(); (a method which switches a boolean "active" to true/false"), on the view, and then calling repaint(); on the view. This repaint method would check if it's active, then draw something different based on whether active is true or false.
first Question is, is this acceptable by MVC standards? I would say yes as it's just drawing, however I believe there shouldn't be calculations in the views methods, is the checking of "active" considered calculations?
Would a better solution be to create a method in the model that can then call the toggle() method on the view, as it is technically changing data? or is it better to just change it directly from the controller. It's certainly easier in a smaller scenario but I can see if it would be confusing for a larger solution.
Not sure if this question is clear enough, let me know and i'll try provide more information.