aspose file tools*
The moose likes Java in General and the fly likes Need help with SwingWorker class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need help with SwingWorker class" Watch "Need help with SwingWorker class" New topic
Author

Need help with SwingWorker class

thejaswini ramesh
Ranch Hand

Joined: Oct 19, 2005
Posts: 74
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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
thejaswini ramesh
Ranch Hand

Joined: Oct 19, 2005
Posts: 74
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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
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

Joined: Oct 19, 2005
Posts: 74
Thanks again!
Yes I have an older version.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
The error message you show is more likely cause by using a version before Java 5, which doesn't understand generics.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Need help with SwingWorker class
 
Similar Threads
Swing InvokeLater ?
Suggestions on making a progress bar/waiting message
Progress / Status update.
Java progress object
aborting a process in java