我被要求在 GWT Composite 中放置一个“完成”按钮(尽管已经有关闭图标),它应该在单击时简单地关闭窗口。不幸的是,我找不到.close()
实现它的方法。如何做呢?
我有一个包含复合组件的 UserDialog 类,我将其命名为 UserComposite。UserDialog 扩展为 CustomDialogBox,CustomDialogBox 扩展为 DialogBox 类:
public class UserDialog extends CustomDialogBox {
private UserComposite c = new UserComposite();
// more codes here
private FlowPanel getFlowPanel() {
if (p instanceof Panel && c instanceof Composite) {
p.setSize(WIDTH, HEIGHT);
p.add(c);
}
return p;
}
}
然后这是我的 UserComposite
public class UserComposite extends Composite {
// codes here
@UiHandler("doneButton")
void onDoneButtonClick(ClickEvent event) {
this.removeFromParent();
}
}
我尝试了 removeFromParent() 但 UserComposite 仅从父级中删除,导致一个空的对话框。