I'm currently experimenting with the SwingWorker class.
I've created a Swingworker Class:
class DownloadWorker extends SwingWorker<Integer, Integer> {
In this class I've overriden the following methods:
@Override protected Integer doInBackground() throws Exception {
and
@Override protected void done() {
However my problem came with the publish and process methods.
I've looked into many online articles but I just cannot fully understand these two methods and ther cooperation.
I've added the following code (just for the sake of the example) in the doInBackground method:
@Override protected Integer doInBackground() throws Exception { for (int i=0; i<10000; i++) { publish(i); } }
When I add the following in the downloadWorker class:
There are no errors but the process method is never executed.protected void process( int a) { System.out.println("process method!: a = " + a); }
So I went looking further for a solution and came up with the following:
I work in netbeans 7.0.1 and netbeans gives me the following error: "name clash: process(java.util.List<java.lang.Object>) in download.DownloadWorker and process(java.util.List<V>) in javax.swing.SwingWorker have the same erasure, yet neither overrides the other"protected void process( java.util.List<Object> chunks) { }
So My next thought was to add an @Override notation.
The moment I do that it gives me the following error:"method does not override or implement a method from a supertype"
At this point I'm really confused and I've got no clue how the process methods works.
If somebody could please point me in the right direction to where I can find a tutorial about this or explain it to me, it would be really helpfull.
Thanks in advance,
Dirk