>Just thought I'd get a consensus of how other developers handle actions
>and what they prefer.
>
>As far as I see it there are many methods to handle actions on e.g. a
>JButton.
>What are the preferences of this newsgroup?
I don't know about 'this newsgroup', but as far as I can see there are
two separate questions here.
1) which class implements the Listener? possibilities being:
a) the class which creates the button (your example 1).
b) an anonymous inner class (your example 2).
c) a private (or protected) named inner class.
d) a dedicated Listener class.
2) How many ActionS should a Listener service? possibilities being:
a) all of them
b) a related group of them
c) one of them
If there aren't too many, I tend to put them all in the same Listener
where I can find them, and if the class won't be sub-classed, then it
may as well be the class itself, so 1a2a.
I never use anonymous inner classes (I think they break up the flow of
the code and make it difficult to see the logic), but I quite often
use combinations of 1c and d with 2b and c, depending upon
circumstances.
Pete Barrett