• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JProgressBar in Napkin look and feel is not working

 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a progressbar without a thread or a timer?
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 507
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 507
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 507
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 507
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 507
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic