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