簡體   English   中英

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

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

我是編程新手。

我有垂直面板。一個按鈕(lblAddFolderIcon)被添加到verticalPanel和一些小部件上。

單擊b1時,應該會出現一個彈出面板,其中包含更多小部件以及兩個帶有添加和取消的按鈕。

我的代碼:

   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建議一些代碼關閉此彈出窗口,以及我的方法是否正確。

嘗試在您取消的onclick中調用hide()

在點擊處理程序的匿名類內部:AddFolderPopup.this.hide();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM