GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Refreshing a JProgressBar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Refreshing a JProgressBar" Watch "Refreshing a JProgressBar" New topic
Author

Refreshing a JProgressBar

Eoin Mac Aoidh
Ranch Hand

Joined: May 19, 2005
Posts: 48
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

Joined: Oct 29, 2001
Posts: 8915
    
    8

If you do a search of this forum for JProgressBar you'll get 46 hits, including this very interesting discussion.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
GeeCON Prague 2014
 
subject: Refreshing a JProgressBar