PDA

View Full Version : Progress bar reset issue



BIGANDYT
8 Sep 2009, 11:30 PM
Hi there im trying to clear a progress bar to its initial state but nothing seems to work ive tried:

_bar.reset();
_bar.clearState();
_bar.updateProgress(0,"");

none of which seem to work, it just sits there at 100%.

Any help would be gratefully recieved, i just dont get it if you have a method called reset...surely it should do its job?! i noticed in a changelog that a progress bar is not allowed to be reset to 0 so didnt expect the third point to work.

Code is as follows:



public class LoadMonitorWidget extends Portlet {

private String _width = "400";
ProgressBar _bar = getProgressBar();

public LoadMonitorWidget() {
this.setStyleName("main");
// this.setPinned(true);
this.setHeading("Load Monitor");
this.setCollapsible(true);
HorizontalPanel headerPanel = new HorizontalPanel();
headerPanel.add(_bar);
this.add(headerPanel);
timerRefresh();

}

private ProgressBar getProgressBar() {
ProgressBar bar = new ProgressBar();
bar.setBorders(true);
bar.setWidth(_width);
bar.setIncrement(10);
return bar;
}

private void timerRefresh() {
Timer timer = new Timer() {

double _x = 0.0;
int _y = 0;

@Override
public void run() {
if (_y != 100) {
_x = _x + 0.1;
_y = _y + 10;
_bar.updateProgress(_x, Integer.toString(_y).concat("%"));
} else {
// reset the bar
_bar.reset()
}

}
};
timer.scheduleRepeating(500);

}
}