SwingWorker<void,void>?

I have the following class declaration:

publicclass blahextends SwingWorker<void,void>

and I get the following error:

Syntax error on token "void", Dimensions expected after this token.

What is the problem?

[351 byte] By [forumusera] at [2007-11-27 5:16:03]
# 1
The problem is that SwingWorker is generic. You must specify the type of the result returned by some of its methods, and you cannot specify void as the type. See the SwingWorker API for examples: http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html
Torgila at 2007-7-12 10:38:30 > top of Java-index,Desktop,Core GUI APIs...
# 2
can't use int either? why can't it be a primative type?
forumusera at 2007-7-12 10:38:30 > top of Java-index,Desktop,Core GUI APIs...
# 3

> can't use int either? why can't it be a

> primative type?

Generics does not work on the primitive type level, so it must be something that derives from Object. You can use Integer instead, and if you want you can take advantage of autoboxing so that your code deals only with ints and not with Integer:

// Silly example to give you an idea of what I mean

class MySwingWorker extends SwingWorker<Integer, Object> {

@Override

public Integer doInBackground() {

return 1 + 2 + 3 + 4;

}

@Override

protected void done() {

int value = get();

...

}

}

Torgila at 2007-7-12 10:38:30 > top of Java-index,Desktop,Core GUI APIs...
# 4
try to capitalize the v's in void public class blah extends SwingWorker<Void,Void>
mruna at 2007-7-12 10:38:30 > top of Java-index,Desktop,Core GUI APIs...