aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JProgressBar in Napkin look and feel is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JProgressBar in Napkin look and feel is not working" Watch "JProgressBar in Napkin look and feel is not working" New topic
Author

JProgressBar in Napkin look and feel is not working

Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Hi,

Please have a look at the following code



In this code, the JProgressBar is not getting updated because of the napkin look and feel. When I change the look and feel to system look and feel, it works fine. Please help.


Are you better than me? Then please show me my mistakes..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

I quote from this thread:
Rob Spoor wrote:Don't use a Thread, use a javax.swing.Timer. Read Concurrency in Swing for more information.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Rob Spoor wrote:I quote from this thread:
Rob Spoor wrote:Don't use a Thread, use a javax.swing.Timer. Read Concurrency in Swing for more information.


Thanks for the reply. My original application will not use either timers or threads. So, I completely removed the thread and tested. Still no good . Please help
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
What is a progressbar without a thread or a timer?
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Michael Dunn wrote:What is a progressbar without a thread or a timer?


It shows how many images has been converted as a progress bar percentage, yes, I am creating a image converting software.
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Michael Dunn wrote:What is a progressbar without a thread or a timer?


errr, anyway, is that is a MUST to use either thread or Timer? But my progressbar has to show the workload done, so things like Thread.sleep(1000) like things cannot be applied.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

Your progress bar needs to show the workload, true, but how do you update it? Do you perform all the processing from an actionPerformed event or any other event on the EDT? If so, then this will block the EDT and therefore will let only the last progress bar value be shown.
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Rob Spoor wrote:Your progress bar needs to show the workload, true, but how do you update it? Do you perform all the processing from an actionPerformed event or any other event on the EDT? If so, then this will block the EDT and therefore will let only the last progress bar value be shown.


err, this is not much clear to me, so I am posting my code with the edits I have mentioned



I can use a timer as you have mentioned, but, according to this code, is it necessary? And, won't it be a performance hit, because if I can do all the operations within 5 seconds, the Thread or Timer will take time to sleep..Please make this clear to me, honestly, this is the first time I am using JProgressBar.
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

OK..I copied a code from the internet to test the timer, and adjusted the napkin look and feel. But unfortunatly that is also not working. The code is below



This look and feel is a trouble maker anyway. So, is there any way to change the look and feel of the progressbar? I mean JUST the progress bar to System look and feel while all other components are napkin. Please help
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
just tested the code in the recent post, and it does actually work.
problem seems to be the napkin l&f paints everything the same color,
the text, the backround, the 'progress' etc - so you don't see any change.

try adding these lines immediately after the indicated line



if you get it working, then change to whatever colors you want
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Michael Dunn wrote:just tested the code in the recent post, and it does actually work.
problem seems to be the napkin l&f paints everything the same color,
the text, the backround, the 'progress' etc - so you don't see any change.

try adding these lines immediately after the indicated line



if you get it working, then change to whatever colors you want


wow, yeah!! It worked Michael!!! Thanks a lot for the help!!! That was great!!
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Rob Spoor wrote:Your progress bar needs to show the workload, true, but how do you update it? Do you perform all the processing from an actionPerformed event or any other event on the EDT? If so, then this will block the EDT and therefore will let only the last progress bar value be shown.


Thanks a lot for the idea about the Timer, Rob!! Now I can stop, start, restart, and pause the workload!!! Amazing!!!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JProgressBar in Napkin look and feel is not working