Link to home
Start Free TrialLog in
Avatar of Cacker
Cacker

asked on

Question on event listeners ..

Hi,

I'm learning Java and have understood that you have to 'implement' any listeners in the class definition to be able to use them.

ie public class ChangeTitle extends JFrame implements ActionListener

I have just entered and run a book example that implements the ActionListener event handler, but not only does the class use the 'addActionListener' method in the class constructor, but in the main() definition for the class it ALSO uses 'addWindowListener' ?????

How can this class use the WindowListener if hasn't 'implemented' it in the class definition.

ie shouldn't the class definition should be ;

public class ChangeTitle extends JFrame implements ActionListener, WindowListener

instead of

public class ChangeTitle extends JFrame implements ActionListener

The small program compiles and runs okay.
ASKER CERTIFIED SOLUTION
Avatar of ozymandias
ozymandias
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial