The low-level event listeners are the ones that have adapters because those listeners have multiple methods, not all of which you may want to implement. The high level event listeners (ActionListener, AdjustmentListener, ItemListener, and TextListener) only have one method each, so there is no reason to provide an adapter class. Corey
Hey guys, when we add an anonymous object to listen to an event say ActionEvent, why do we write Button b; b.addActionListener( new ActionListener() {..}); i.e when ActionListener is an interface, how can we write new ActionListener().
In such a case, you're not really creating a new ActionListener (as that's impossible). Rather, a new anonymous class is created that extends Object and implements ActionListener. That's the object that really gets created. If you were to add this line inside the ActionListener object:
You'd see something like this getting printed out (assuming that the class MyFrame is where this ActionListener is created):
Notice, it doesn't have a type of ActionListener, it is actually an inner class of the class MyFrame and it is assigned a class name of 1. I hope that helps, Corey
Since you mentioned that you just bought Rasmussen and Mughal in your other post, flip to page 245 for a discussion of what is happening in this situation. Corey