GWT-DialogBox.center()无法正常工作 [英] GWT - DialogBox.center() doesn't work correctly

查看:70
本文介绍了GWT-DialogBox.center()无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有一张带有按钮的表格.按钮太多了,以至于我有一个滚动器可以向下滚动表格.

There's a table with buttons on my page. There're so much buttons, that I have a scroller to scroll down my table.

按钮"onClick"将生成一个包含滚动面板,内容和关闭此对话框的按钮的对话框.我使用DialogBox.center()将其居中.按下时,假设表格中的第一个按钮,对话框严格显示在中央....但是当我向下滚动页面并按下表格底部的按钮时,我的DialogBox仍显示在旧"对话框中中心...几乎在我的视野之上.它只是不会根据我的滚动条位置向下移动. 我试图更改setPopupPosition(),setPopupPositionAndShow()等等,但是没有帮助.

Button "onClick" generates a dialog box with scrollpanel, content and a button to close this dialog box. I center it using DialogBox.center(). When I press, let's say the first button in a table, dialog box appears strictly in the center.... but when I scroll down the page and press button in the bottom of my table, my DialogBox still appears in the "old" center...almost above my view. It simply doesn't move down according to my scrollbar position. I tried to change setPopupPosition(), setPopupPositionAndShow() and so on, but it didn't help.

有什么主意吗?这是我对话框的一些代码:

Is there any ideas what is wrong? Here is some code of my dialog box:

public class MyDialogBox extends DialogBox {

    public MyDialogBox(final String caption, final String text) {
        setText("Caption: " + caption);

        VerticalPanel inner = new VerticalPanel();
        Label msg = new Label(text);

        Button ok = new Button("Close");
        ok.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                    MessageTextBox.this.hide();
                }
        });

        inner.add(msg);
        ScrollPanel scrollbar = new ScrollPanel(inner);
        scrollbar.setSize("640", "480");
        VerticalPanel outer = new VerticalPanel();
        outer.add(scrollbar);
        outer.add(ok);
        setWidget(outer);
    }
}

这是我的按钮的调用方式:

And here is how my button call it:

VerticalPanel mainPanel ... //MainPanel with a lot different elements, it contains panel with buttons
VerticalPanel panel ... //Panel with buttons
panel.setViewButtonHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
        MyDialogBox dialogBox = new MyDialogBox("Caption", "Some text");
        dialogBox.center();
        dialogBox.show();
     }
});
mainPanel.add(panel);

推荐答案

提到的问题的来源似乎非常简单. Chrome无法正确居中对话框.我检查了FF,IE ...并按计划工作.

The source of mentioned problem appeared to be very simple. Chrome doesn't center dialog box correctly. I checked with FF, IE... and it works as it was planned.

这篇关于GWT-DialogBox.center()无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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