• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with SwingWorker class

 
thejaswini ramesh
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I have to display a progress bar to the user while a background task is being performed.

I tried an example from Sun's trail
http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html

But am getting a compilation error for the SwingWorker class. Am not sure how this class works since I've never used it before. Can someone tell me how to get the pgm ProgressBarDemo2.java to work?

Thanks in Advance,
Thejaswini.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of error are you getting?

Also, which JDK version are you using? The Java Tutorial generally uses the latest version, and that page mentions Java 6 several times. So if you're using an earlier JDK, you may have to adapt the code.
 
thejaswini ramesh
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

Thanks for the reply.
Am getting an error like this:
C:\Documents and Settings\thejaswini>javac c:\ex\ProgressBa
rDemo2.java
c:\ex\ProgressBarDemo2.java:18: '{' expected
class Task extends SwingWorker<Void, Void> {
^
1 error

Do you suggest that I upgrade my JDK in order to compile the file?

Thejaswini.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you suggest that I upgrade my JDK in order to compile the file?


If you don't have JDK 6, then yes. (The SwingWorker class was introduced in Java 6.)
 
thejaswini ramesh
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again!
Yes I have an older version.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message you show is more likely cause by using a version before Java 5, which doesn't understand generics.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic