• Post Reply Bookmark Topic Watch Topic
  • New Topic

JProgressBar shows no progress  RSS feed

 
Smilidon Sapiens
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I write a little java app, where you can open a file and you see the content of the file in a textarea. When the file is loading, a progressBar should show the loaded bytes. My progressbar shows nothing.. bad or?
Can you help me please? The ProgressBar is changed in the method "openFile(..)".

[ January 31, 2002: Message edited by: Brain Tenner ]
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brian,
Your problem is not in how you are updating the JProgressBar but rather in how you are trying to dynamically show it.
When you add a component to a panel you need to tell the panel to perform its' layout magic on all its children including the newly added one. You are missing that hint to the panel. All you need is one line and all will work as expected.
Inside your OpenFile method immediately after the line:
panel.add("North",jpb);
place a new line that looks like this:
panel.validate();
and then your program works much better!
Regards,
Manfred.
 
Smilidon Sapiens
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thanks for your fast reply!
I changed my method to this:

There is still my problem...
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brian,
Sorry I also made another change that I forgot to mention. The code below works like you have proposed. I have bolded my changes (I think all of them!).

Enjoy,
Manfred.
 
Smilidon Sapiens
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it works, great!!! I'm happy...
It flickers a bit, is there a way to stop it?
Greetings Brain!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!