Is ActionListener in controller for Java GUI App good idea?

后端 未结 4 2011
小蘑菇
小蘑菇 2021-01-01 07:06

I\'t trying to follow MVC pattern. In internet as I see the most famous example is calculator, for example here. I began to use this implementation of MVC pattern. But now I

4条回答
  •  粉色の甜心
    2021-01-01 07:32

    All logic should be placed in the controller. However there is no strict line, some very simple logic could be fine inside the view. Place actionListeners in controller and then your buttons in GUI. That's how I normally do. Sometimes I'm lazy and let my buttons implement actionListeners and let them listen on themselves, in this case i put buttons inside controller package.

提交回复
热议问题