Success is not doing extraordinary things but doing ordinary things extraordinarily well.
Originally posted by Campbell Ritchie:
I think is is very unfortunate that the Java tutorial uses addActionListener(this) passim.
There is no emoticon for what I am feeling!
A class can't be any number of objects. A class is a class, but it may be instantiated to give rise to objects. And unless it is a Singleton type, the "client" classes can instantiate as many objects from it as they like.A class should try to be a single object. Not multiple different ones.
Originally posted by Campbell Ritchie:
Oh, if he was referring to addActionListener(this) . . .
Sorry for mouthing off, I was wrong to do that. We are in full agreement that in most cases addAnythingListener(this) is an abomination against good programming.
There is one instance where addAnythingListener(this) is good practice. that is where the listener actually refers to the state of the Component. If you want to do anything with the position of the mouse pointer, for example, then you would want the MouseListener in the Component.
Attractive, successful people love this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|