Unable to override process () method in SwingWorker

I have a SwingWorker class as follows:

    class RemotePlayersWorker extends SwingWorker<String[][], Object> {
        PlayerCanvas parent;
        RemoteHandler remote;
        String[][] players;
        int maximumConnections;

        public RemotePlayersWorker(PlayerCanvas parentCanvas, RemoteHandler remoteHandle) {
            this.parent = parentCanvas;
            this.remote = remoteHandle;
        }

        @Override
        protected String[][] doInBackground() throws Exception {
            System.out.println("TEST 1");
            players = remote.getConnectedPlayers();
            publish(players);
            return players;
        }

        @Override
        protected void process(List<String[][]> chunks) {
            for (String[][] chunk : chunks) {
                 // no need for the c variable
                 System.out.println(chunk.toString());
              }
        }

        @Override 
        protected void done() {

        }
    }

However, I get errors when overriding the method (List chunks). Eclipse tells me this:

The method process(List) of type PlayerHandler.RemotePlayersWorker must override or implement a supertype method

However, as far as I can tell, I am correctly redefining the method - I get the same error, regardless of what I set the list type for.

Is there any other reason why I could not override process ()?

I am using the java version "1.7.0_10" - Java (TM) SE Runtime Environment (build 1.7.0_10-b18)

+5
source share
3 answers

The SwingWorker class is defined as follows:

public class SwingWorker<T, V> {
    ...
    protected void process(List<V> chunks) {
        ...
    }
}

So, since your subclass is declared as

class RemotePlayersWorker extends SwingWorker<String[][], Object> {

List<Object> , List<String[][]>

+6

process(),

protected void process(List<Object> chunks) {
   /// do your stuff
}

2-. SwingWorker. , .

:

public class SwingWorker<T, V> {

    // methods

    protected void process(List<V> chunks) {
       // do your stuff
    }
}

, process() V, Object.

, List<Object>, SwingWorker ( doInBackground()).

+4

.

SwingWorker: protected void process(List<V> chunks)

V - , SwingWorker

, :

protected  void process(List<Object> chunks)
+3

All Articles