如何在中心放置 Vaadin 确认对话框确定和取消按钮 [英] How to place Vaadin confirmdialog ok and cancel button in center

查看:32
本文介绍了如何在中心放置 Vaadin 确认对话框确定和取消按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 ConfirmDialog add-on 来自 Vaadin 目录.

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

是否可以将 OKCancel 按钮放在窗口中央?默认情况下,它位于窗口的右上角.

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.

推荐答案

只需创建一个中间有按钮的布局,并将其设置为 ConfirmDialog 的内容即可.您可以使用 ConfirmDialog.get...Button() 获取按钮.示例:

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

不过,我同意 Jan 的看法,最好的做法是将它们放在右下角.

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

这篇关于如何在中心放置 Vaadin 确认对话框确定和取消按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆