我在垂直面板内有两个水平面板,水平面板由标签和文本框组成。无论如何我可以对齐文本框吗?
//create a vertical panel
VerticalPanel vpanel = new VerticalPanel();
//create a hortizontal panel for customer name
HorizontalPanel hcustomer = new HorizontalPanel();
hcustomer.setSpacing(2);
Label customerlabel = new Label("Customer Name: ");
final TextBox customerTb = new TextBox();
hcustomer.add(customerlabel);
hcustomer.add(customerTb);
//create a horizontal panel for caller number
HorizontalPanel hcaller = new HorizontalPanel();
hcaller.setSpacing(2);
Label callerlabel = new Label("Caller Number: ");
final TextBox callerTb = new TextBox();
hcaller.add(callerlabel);
hcaller.add(callerTb);
callerTb.setMaxLength(10);
callerTb.addBlurHandler(new BlurHandler() {
@Override
public void onBlur(BlurEvent blurEvent) {
reformatPhone(callerTb);
}
});
//add widget into vpanel
vpanel.add(hcustomer);
vpanel.add(hcaller);
我想我可以手动在hortizontalpanel中进行设置调整以使它们对齐,但我再次认为必须有一种更简单的方法。
答案 0 :(得分:0)
vpanel.setWidth("100%");
hcustomer.setWidth("100%");
hcaller.setWidth("100%");