I’m still a student and I’m not sure what is correct structure for an ActionListener ? is it completely ok to just leave them in the layout constructor ? I don’t want to train myself bad habits this early on…
to clarify I’m using google’s web toolkit which creates action listeners by default in the constructor however prior to that I used ActionListenerHandler (which is sorta a constructor by itself)
I believe the answer is.. it depends..
If it is a one off thing.. you can leave it in the constructor, I assume what you have is anonymous class implementing the ActionListener.
If you want to reuse the ActionListener. You can create a class to implement the ActionListener and simply create instances of that class.
I think some developers don’t like creating ActionListeners in the View. Some think it adds logic into a View.
Maybe your View should really expose a method
addSomeActionListener(ActionListener actionListener);