• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Refreshing a JProgressBar

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am having trouble refreshing the progress bar in my application. Its value is being updated, however the bar does not move...
I set up my progress bar:

public StatusBar(){
pbar = new JProgressBar();
pbar.setMinimum(MYMINIMUM);
pbar.setMaximum(MYMAXIMUM);
pbar.setValue(5); //to show that some progresss is underway initially
add(pbar);
}

Then in the main class I set the progressbar up in a pop up window of its own using getStatusBar:

public void getStatusBar(){
StatusBar sb = new StatusBar();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(sb);

frame.setLocation(300,300);
frame.pack();
frame.setVisible(true);
}

when I want the bar to show progression I call its UpdateBar method:

public void updateBar(){
System.out.println("Updating status bar");
pbar.setValue(45);

/**The pbar object can be accessed - I can get its value.
* and I can set it - the print statement shows its value is being updated, but the actual visual display of the bar dosnt change!
**/

while(inc<100){
pbar.setValue(inc);
inc = inc + 5;
//System.out.println(pbar.getValue());
}
}

Any ideas why this isnt refreshing?

Thanks,

Eoin.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you do a search of this forum for JProgressBar you'll get 46 hits, including this very interesting discussion.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic