silv
29 Jul 2009, 6:59 PM
Posting here as I'm not sure having a ProgressBar in a FormPanel is valid. (It is there to show progress on a file upload.)
But, if you do put it there, the text left-aligns instead of center like it does outside of a FormPanel.
Example code:
public class Samplebug implements EntryPoint {
static float percent = 0;
public void onModuleLoad() {
Viewport v = new Viewport();
v.setLayout(new FitLayout());
FormPanel f = new FormPanel();
f.setLayout(new FormLayout());
final ProgressBar prg = new ProgressBar();
prg.setHideMode(HideMode.OFFSETS);
prg.hide();
final Timer t = new Timer() {
public void run() {
percent +=1;
prg.updateProgress(percent / 100, Float.toString(percent));
}
};
Button b = new Button("Go");
b.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
t.scheduleRepeating(500);
prg.show();
prg.reset();
}
});
f.add(prg);
f.add(b);
v.add(f);
RootPanel.get().add(v);
}
}
But, if you do put it there, the text left-aligns instead of center like it does outside of a FormPanel.
Example code:
public class Samplebug implements EntryPoint {
static float percent = 0;
public void onModuleLoad() {
Viewport v = new Viewport();
v.setLayout(new FitLayout());
FormPanel f = new FormPanel();
f.setLayout(new FormLayout());
final ProgressBar prg = new ProgressBar();
prg.setHideMode(HideMode.OFFSETS);
prg.hide();
final Timer t = new Timer() {
public void run() {
percent +=1;
prg.updateProgress(percent / 100, Float.toString(percent));
}
};
Button b = new Button("Go");
b.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
t.scheduleRepeating(500);
prg.show();
prg.reset();
}
});
f.add(prg);
f.add(b);
v.add(f);
RootPanel.get().add(v);
}
}