Compiling error about Abstracts?
I get this error message when I compile the code at the bottom: "Runner is not abstract and does not override abstract method itemStateChanged(java.awt.event.ItemEvent) in java.awt.event.ItemListener"
Here is my snipped code:
publicclass Runnerextends clientimplements ActionListener, ItemListener
<snip>
publicvoid itemStateChanged(ItemEvent evt)
<snip>
publicvoid actionPerformed(ActionEvent evt)
The itemStateChanged and actionPerformed are both inside the Runner class brackets, but not anything else.
Does anybody know why I get that error message?
With all of the research I did, the only reason the compiler should complain is if I don't have the itemStateChanged at all, but I do...
Thanks for any help. Also, I snipped a whole bunch of code, so I didn't provide enough, let me know.
[1141 byte] By [
Heathtecha] at [2007-11-27 5:28:03]

> public void itemStateChanged(ItemEvent evt)Have you verified that you are importing the correct ItemEvent? Are you also 100% sure that the implementation isn't placed in a nested class or an innerclass?Kaj
kajbja at 2007-7-12 14:50:04 >

I'm pretty sure that the implementation takes place in the outermost class because it is called directly under the imports (which aren't in any class).
As for the ItemEvent, you might need to explain how I would verify that. Do you mean the "evt" or what? Here is a little bit that is inside that itemStateChanged:
String txt = evt.paramString();
txt = txt.substring(txt.indexOf("files: " + 7));
int stateChange = evt.getStateChange();
This kind of Java programming is a little over my head. I can program in Java to a point, but when it goes into extends and implements... yeah...
> I'm pretty sure that the implementation takes place
> in the outermost class because it is called directly
> under the imports (which aren't in any class).
What?
Is this what your code looks like:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class Runner extends client implements ActionListener, ItemListener {
public void itemStateChanged(ItemEvent evt) {
}
public void actionPerformed(ActionEvent evt) {
}
}
Kaj
kajbja at 2007-7-12 14:50:04 >

Sorry to double post, but editing is disabled...
I just realized what you meant by importing the ItemEvent. I already had "import java.awt.event.*;" but that didn't import it, I guess. All I did was add "import java.awt.event.ItemEvent;" and it compiled without any problems!
Thank you for that information, but can you tell me why I had to import what was already supposed to be imported? Thanks.
> Sorry to double post, but editing is disabled...
>
> I just realized what you meant by importing the
> ItemEvent. I already had "import java.awt.event.*;"
> but that didn't import it, I guess. All I did was
> add "import java.awt.event.ItemEvent;" and it
> compiled without any problems!
>
> Thank you for that information, but can you tell me
> why I had to import what was already supposed to be
> imported? Thanks.
Are you sure you didn't have any other compiler errors before?
That change does not explain the difference between what the error you had and being fixed...
You didn't by accident write a class ItemEvent in the same package your Runner class is defined? When your compiler looks up the class to use, it uses the one that can be resolved in the own package unless it finds an explicitly imported match...
If you import 2 packages that contain a class with the same name, but you don't explicitly include one of them you get naming clashes...
If you are using eclipse or probably any IDE you can test this by reverting to your original state and ctrl+click the ItemEvent in the definition to see where you end up. Or you could just point your mouse over 'ItemEvent' and you see what the definition used is...
Message was edited by:
Peetzore