I got two JButton that implements the same ActionListener.
This ActionListener need to call a function on my other object which i will call container just for the sake of this question.
Because two classes uses ActionListener I made it a outer-class.
Just to give a context, button1 is a JMenuItem and button2 is a JButton on a JToolBar uses my ActionListener and are not directly linked to container. container is a JPanel in a JPanel in a Jpanel.
I thought to register container to my ActionListener, just like i would do with an Observer pattern and keep an ArrayList containing, but i'm not sure if it is the good approach.
I've read about the Visitor pattern, but honestly i don't quite see the difference with the Observer pattern.
What i understand from a Bridge pattern is that i decouple the object so two distinct object can evolve indepently from each other.
Is there another approach I did'nt explore that would be better?
I find the issue confusing so my question is probably confusing as well. Let me know if you need more specificity.
Aucun commentaire:
Enregistrer un commentaire