通过单击其子面板中的按钮关闭弹出面板

时间:2012-05-14 05:15:42

标签: gwt popuppanel

我有以下Panel层次结构:

自定义面板1 包含 PopupPanel 包含 DecklayoutPanel 包含 CustomPanel 2 包含 FlowPanel 包含按钮

如何通过单击按钮关闭自定义面板1或PopupPanel?

1 个答案:

答案 0 :(得分:1)

// CustomPanel2

class CustomPanel2 {
  @UiField Button closeButton;

  public CustomPanel2() {
    initWidget(uiBinder.createAndBindUi(this));
  }

  public HasClickHandlers closeButton() {
    return closeButton;
  }
}

// CustomPanel1

class CustomPanel1 implements ClickHandler {
  @UiField PopupPanel myPopupPanel;
  @UiField CustomPanel2 customPanel2;

  public CustomPanel1() {
    initWidget(uiBinder.createAndBindUi(this));
    customPanel2.closeButton().addClickHandler(this);
  }

  @Override
  public void onClick(ClickEvent e) {
    myPopupPanel.hide();
  }
}