Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Question on event listeners ..

Posted on 2002-04-19
1
202 Views
Last Modified: 2010-03-31
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.
0
Comment
Question by:Cacker
1 Comment
 
LVL 15

Accepted Solution

by:
ozymandias earned 25 total points
ID: 6953941
JFrame is a subclass of java.awt.window which has a method called addWindowListener(). The method you see in the JFrame is calling that method. It is a feature of inheritance.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Arrays.asList  VS  ArrayList 4 71
servlet and mdb, jms error 1 33
learn programming 8 39
American Express @Work site and Java 4 23
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question