WindowListener Required Methods Not Recognized

H

Hal Vaughan

This may be more of a problem with Eclipse, but after setting up the class
and getting an error, I complied it and still get the same errors from the
compiler. I have the class below. It's just a framework now and I'll be
adding more later. When I wrote it, I had "implements ActionListener" and
included actionPerformed() and there was no problem, but when I added the
WindowListener methods and added that it implemented WindowListener, I keep
getting errors like this:

The type SedFrame must implement the inherited abstract method
WindowListener.windowIconified(WindowEvent)

Just in case the method I put in wasn't recognized, I cut it then pasted it.
The error may change to a different method, but I keep getting the same
problem. I do have a learning disability so I've actually gone back and
cut and pasted the names of the methods in place to be sure they're spelled
right (since there's no spellchecker for the IDE). I still get the same
errors.

Why aren't the methods accepted as the ones needed by a WindowListener?

Thanks!

Hal
--------------
public class SedFrame extends JFrame implements ActionListener,
WindowListener {

public void windowActivated(WindowEvent wEvent) {
return;
}

public void windowDeactivated(WindowEvent wEvent) {
return;
}

public void windowOpened(WindowEvent wEvent) {
return;
}

public void windowClosed(WindowEvent wEvent) {
return;
}

public void windowClosing(WindowEvent wEvent) {
return;
}

public void windowDeiconified(WindowEvent wEvent) {
return;
}

public void windowIconified(WindowEvent wEvent) {
return;
}

public void actionPerformed(ActionEvent aEvent) {
return;
}

//Other methods, including a constructor are also included...

}
 
J

Jeff Higgins

Hal said:
This may be more of a problem with Eclipse, but after setting up the class
and getting an error, I complied it and still get the same errors from the
compiler. I have the class below. It's just a framework now and I'll be
adding more later. When I wrote it, I had "implements ActionListener" and
included actionPerformed() and there was no problem, but when I added the
WindowListener methods and added that it implemented WindowListener, I
keep
getting errors like this:

The type SedFrame must implement the inherited abstract method
WindowListener.windowIconified(WindowEvent)

Just in case the method I put in wasn't recognized, I cut it then pasted
it.
The error may change to a different method, but I keep getting the same
problem. I do have a learning disability so I've actually gone back and
cut and pasted the names of the methods in place to be sure they're
spelled
right (since there's no spellchecker for the IDE). I still get the same
errors.

Why aren't the methods accepted as the ones needed by a WindowListener?

Thanks!

With addition of proper imports,
compiles without error in Eclipse and on command line,
except I don't have any:
//Other methods, including a constructor are also included...
 
E

Eric Sosman

Hal Vaughan wrote On 07/02/07 12:29,:
This may be more of a problem with Eclipse, but after setting up the class
and getting an error, I complied it and still get the same errors from the
compiler. I have the class below. It's just a framework now and I'll be
adding more later. When I wrote it, I had "implements ActionListener" and
included actionPerformed() and there was no problem, but when I added the
WindowListener methods and added that it implemented WindowListener, I keep
getting errors like this:

The type SedFrame must implement the inherited abstract method
WindowListener.windowIconified(WindowEvent)

Just in case the method I put in wasn't recognized, I cut it then pasted it.
The error may change to a different method, but I keep getting the same
problem. I do have a learning disability so I've actually gone back and
cut and pasted the names of the methods in place to be sure they're spelled
right (since there's no spellchecker for the IDE). I still get the same
errors.

Why aren't the methods accepted as the ones needed by a WindowListener?
[code snipped; see up-thread]

It compiles fine for me. Do you have any classes of
your own named WindowEvent or something? A class that
implements java.awt.event.WindowListener must provide
methods that take java.awt.event.WindowEvent parameters;
a method taking com.vaughan.hal.WindowEvent would not
fill the bill.
 
H

Hal Vaughan

Jeff said:
With addition of proper imports,
compiles without error in Eclipse and on command line,
except I don't have any:
//Other methods, including a constructor are also included...

I had ruled out imports and forgot to post that they were set up. I'm glad
I did. The key word was "proper." Without realizing it, when I had told
Eclipse to organize the imports, I had clicked on the window accepting
which WindowEvent to import and that was the wrong one. I deleted the
imports associated with WindowEvent and WindowListener, organized the
imports again and when it asked which WindowEvent, I realized what had
happened.

It's working now.

Thanks to all who have replied to help!

Hal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top