How to place Vaadin confirmdialog ok and cancel bu

2019-08-05 18:38发布

I have been using the ConfirmDialog add-on from the Vaadin Directory.

Is it possible to put the OK and Cancel buttons in the center of the window? By default it is in the right corner of the window.

标签: vaadin
2条回答
甜甜的少女心
2楼-- · 2019-08-05 19:08

Keeping the buttons in the right lower corner is good practice when it comes to usability. Have a look at http://uxmovement.com/buttons/why-ok-buttons-in-dialog-boxes-work-best-on-the-right/ for more details. I would advice not to sacrifice behavior conventions for personal taste.

查看更多
仙女界的扛把子
3楼-- · 2019-08-05 19:24

Just create a layout with buttons in the middle and set it as the content of ConfirmDialog. You can get the buttons using ConfirmDialog.get...Button(). Example:

    ConfirmDialog cd = ConfirmDialog.getFactory().create("Title", "", "OK",
            "Cancel");
    cd.setHeight("400px");
    cd.setWidth("400px");
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.addComponent(cd.getCancelButton());
    buttons.addComponent(cd.getOkButton());
    VerticalLayout content = new VerticalLayout(buttons);
    content.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
    content.setSizeFull();
    cd.setContent(content);
    cd.show(this, null, false);

However I agree with Jan that the good practice is having them in the bottom right corner.

查看更多
登录 后发表回答