我的页面上有一张有按钮的桌子。 有很多按钮, 我有一个滚动器可以滚动到桌子上。
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.
有什么想法吗?这是我对话框的代码:
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);
}
}
这就是我的按钮怎么称呼它:
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);