Event handling ideas

95 views Asked by At

I have two classes extended from JPanels and both the panels have buttons which when clicked perform a common activity. What will be the best way to achieve this? Does event delegation enter here? like passing the control to handler on another class? (I have assumed thats what delegation is, if I am not wrong)(If delegation is suitable pls provide some good study resource). I have also thought of having a common static method and each classes actionPerformed might call that!! Or is there any other better way?

1

There are 1 answers

2
dogbane On

Consider using an Action object, if you have two or more components which perform the same function when acted upon.

Take a look at the Tutorial | How to Use Actions for more information.