简体   繁体   English

如何在Gwt中的PopupPanel中添加取消按钮

[英]How to add cancel button in PopupPanel in Gwt

I am new to programming. 我是编程新手。

I have vertical panel.A button(lblAddFolderIcon) is added on the verticalPanel and also some widgets. 我有垂直面板。一个按钮(lblAddFolderIcon)被添加到verticalPanel和一些小部件上。

on click of b1 there should be a popup panel with some more widgets and two button with add and cancel. 单击b1时,应该会出现一个弹出面板,其中包含更多小部件以及两个带有添加和取消的按钮。

My Code: 我的代码:

   lblAddFolderIcon.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String childFolder = item.getText();
            String[] mainRepository=getPath(item);
            String objectId=item.getTitle();

            final AddFolderPopup addFolderPopup = new AddFolderPopup(childFolder,mainRepository[0],objectId);
            addFolderPopup.setHeight("300px");
            addFolderPopup.setWidth("502px");
            addFolderPopup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {

                public void setPosition(int offsetWidth, int offsetHeight) {
                    // TODO Auto-generated method stub
                    int left = (Window.getClientWidth() - offsetWidth) / 3;
                    int top = (Window.getClientHeight() - offsetHeight) / 3;
                    addFolderPopup.setPopupPosition(left, top);
                }
            });
            //addFolderPopup.show();
            addFolderPopup.addFolderGui();
        }
    });

    public class AddFolderPopup extends PopupPanel {
VerticalPanel vpPopupl = new VerticalPanel();
private String childFolder;
private String mainRepository;
private String objectId;

public AddFolderPopup(){
    super(true);
}
public AddFolderPopup(String childFolder, String mainRepository, String objectId) {
    this.childFolder = childFolder;
    this.mainRepository = mainRepository;
    this.objectId = objectId;   

}
public void addFolderGui() {
         // some widget to design Gui and
      Button btnCancel = new Button("Cancel");
    btnCancel.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
                               /* i Dont Know what should i write here 
                                  so that this popupwindow is closed
                                */
                }
    });
      }
    }

Plz suggest some code to close this popup window and also whether my approach is correct. Plz建议一些代码关闭此弹出窗口,以及我的方法是否正确。

尝试在您取消的onclick中调用hide()

在点击处理程序的匿名类内部:AddFolderPopup.this.hide();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM