Hi y'all. I'm looking for feedback and discussion on the use of annotations to eliminate the boilerplate code for linking buttons and methods. Hopefully this will be especially useful in RAD or rapid prototyping environments.
Over the weekend I hacked together a little proof of concept that supports two ways of doing this - one by annotating the button with the name of its associated method, the other by annotating the method with the name of its associated button...
@ActionMethod(name = "okMethod")
JButton okButton = new JButton("OK");
or
@ActionMethod(button = "okButton")
public void okMethod(ActionEvent e) { ...
All that's required from the "user" is a single call
ActionMethodHandler.activate(this);
In either case, in the background I use reflection on the class to find these annotations and add an action listeners to the buttons to call the methods.
So - opinions please
Is this a good idea or should I bury it quickly before it does any harm?
If it is a good idea, which version is better, any why?
Is there a third option that's better than both?
Don't be shy.
J