1

我有以下面板层次结构:

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

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

4

1 回答 1

1

// 自定义面板2

class CustomPanel2 {
  @UiField Button closeButton;

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

  public HasClickHandlers closeButton() {
    return closeButton;
  }
}

// 自定义面板1

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();
  }
}
于 2012-05-14T07:30:33.967 回答