File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refreshing a JProgressBar

 
Eoin Mac Aoidh
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic