can't implement PropertyChangeListener

I am trying to make a progress bar, and according to the tutorial on Sun's website I need to add a PropertyChangeListener. The problem is when I compile it I get an error

"class" is not abstract and does not override abstract method propertyChange(java.beans.PropertyChangeEvent) in java.beans.PropertyChangeListener

My other issue is that it doesn't recognize Task().

Here is part of the code

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.util.*;

import javax.swing.*;

import javax.swing.event.*;

import java.beans.*;

publicclass RunMethodimplements PropertyChangeListener{

publicvoid runMethod(String filename, String file2name)throws IOException{

JProgressBar progressBar =new JProgressBar(0, maximum);

progressBar.setValue(0);

progressBar.setStringPainted(true);

progressBar.setBorderPainted(true);

task =new Task();

task.addPropertyChangeListener(this);

task.execute();

}

}

I haven't bothered to write the PropertyChangeListener method yet....

Thanks

[1839 byte] By [snoboardera] at [2007-11-27 5:58:01]
# 1

> "class" is not abstract and does not override abstract method

> propertyChange(java.beans.PropertyChangeEvent) in

> java.beans.PropertyChangeListene

That's because - as you say at the end - "I haven't bothered to write the PropertyChangeListener method yet...". The point is that your class says that it implements PropertyChangeListener and that means that it promises to implement the methods of that interface. If you don't (and you haven't) the compiler will grumble. You can write an "empty"public void propertyChange(PropertyChangeEvent evt) {}

> My other issue is that it doesn't recognize Task().

Task is not part of the Java API, so you have to write this class yourself. There is a discussion about what it is in the tutorial (it's a subclass of SwingWorker) and you will find the implementation that the tutorial uses newar the start of ProgressBarDemo.java.

pbrockway2a at 2007-7-12 16:31:54 > top of Java-index,Java Essentials,New To Java...
# 2
> "class" is not abstract and does not override abstract method propertyChangeThe error message is self evident. You haven't implemented the propertyChange method.What is the Task class? One you have written? One given to you/downloaded?
floundera at 2007-7-12 16:31:54 > top of Java-index,Java Essentials,New To Java...
# 3
And that worked, I can't believe I forgot that neglecting that method was the issue. I guess the error message kinda threw me off.Thanks, that really helpsp.s. and yeah, I wasn't aware Task() was not in the API
snoboardera at 2007-7-12 16:31:54 > top of Java-index,Java Essentials,New To Java...
# 4
How could the error message throw you off when it told you exactly what was wrong?
ejpa at 2007-7-12 16:31:54 > top of Java-index,Java Essentials,New To Java...
# 5
im just learning, and when it said something about being overridden, I assumed it had something to do with the parent class...
snoboardera at 2007-7-12 16:31:54 > top of Java-index,Java Essentials,New To Java...
# 6
But there was no need to assume anything!> 'does not override abstract method propertyChange'
ejpa at 2007-7-12 16:31:54 > top of Java-index,Java Essentials,New To Java...