Event handling ideas
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 a开发者_开发知识库m 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?
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.
精彩评论