首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将DynamicForm水平对齐到VLayout中心

将DynamicForm水平对齐到VLayout中心
EN

Stack Overflow用户
提问于 2015-12-16 15:36:04
回答 1查看 879关注 0票数 0

是否有可能使DynamicForm水平对齐到VLayout的中心?我已经尝试过在展示演示中所做的工作,但是它对表单不起作用(对于IButton确实是正确的)。

这是我的代码:

代码语言:javascript
复制
public class PreferencesStackSection extends SectionStackSection {

    private static final String SAVE_ICON = "icons/save.png";
    private static final int COMPONENT_GAP = 10;

    // Object used to get access to internationalization constants and messages
    private BMSimulatorConstants constants = GWT.create(BMSimulatorConstants.class);

    private DataSource ds;
    private DynamicForm form;
    private IButton saveBtn;

    public PreferencesStackSection(String title) {
        super(title);
        ds = DataSource.get("preferences");
        buildPreferencesLayout();
    }


    private void buildPreferencesLayout() {
        VLayout layout = new VLayout(COMPONENT_GAP);
        layout.setMargin(COMPONENT_GAP * 2);
        layout.setDefaultLayoutAlign(Alignment.CENTER);
        createPreferencesForm(layout);
        createSaveButton(layout);
        this.addItem(layout);
    }

    private void createPreferencesForm(VLayout layout) {
        form = new DynamicForm();
        form.setNumCols(1);
        form.setTitleOrientation(TitleOrientation.TOP);
        form.setDataSource(ds);
        layout.addMember(form);
    }

    private void createSaveButton(VLayout layout) {

        saveBtn = new IButton(constants.preferencesSaveButton());
        saveBtn.setIcon(SAVE_ICON);
        saveBtn.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {

                DSCallback callback = new DSCallback() {
                    public void execute(DSResponse response, Object rawData, DSRequest request){
                        SC.say(constants.preferencesSavedOK());
                    }
                };

                form.saveData(callback);
            }
        });
        layout.addMember(saveBtn);
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-18 02:44:43

这解决了问题(行的顺序对于它的工作非常重要):

代码语言:javascript
复制
private void createPreferencesForm(VLayout layout) {
    form = new DynamicForm();
    form.setDataSource(ds);
    form.setNumCols(1);
    form.setTitleOrientation(TitleOrientation.TOP);
    layout.addMember(form);
    form.setWidth("70%");
    for(FormItem item: form.getFields()){
        item.setWidth("*");
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34316051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档