0

当用户触摸屏幕时,我正在显示一个对话框,并希望在用户触摸对话框外的任何位置时释放对话框。我已经设置setDisposeWhenPointerOutOfBounds()true默认情况下它是。而且我在pointerReleased()事件中编写了以下代码,但是每当用户在对话框之外触摸屏幕时,对话框就会释放,但不会不执行仅当 x,y 在对话框中时才应执行的代码。

public void pointerReleased(int x, int y) {
    dispose();
    if (contains(x, y)) {
        actionCommand((cmds[l.getSelectedIndex()]));
    }
}
4

1 回答 1

1

该错误在检查中contains(x,y)。我用它替换它this.getContentPane.contains(x,y)并解决了这个问题

于 2010-02-27T09:44:25.870 回答