PDA

View Full Version : ProgressBar text left-aligns if it is in a FormPanel



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);
}
}

Arno.Nyhm
30 Jul 2009, 7:28 AM
if i change it to this then the Text is in center:


prg.setHideMode(HideMode.VISIBILITY);

silv
30 Jul 2009, 7:54 AM
At what point do you need to set that? If you do it initially when it is hidden it will do the original behavior of sliding the text across.

silv
30 Jul 2009, 8:01 AM
Nevermind. You are correct, setting it to VISIBILITY instead of OFFSETS fixes it...