boolean (AWTEvent event) { if (event.getID() != MouseEvent.MOUSE_PRESSED) { return false; } if (myStack.isEmpty()) { return false; } AbstractPopup popup = (AbstractPopup)findPopup(); final MouseEvent mouseEvent = (MouseEvent) event; Point point = (Point) mouseEvent.getPoint().clone(); SwingUtilities.convertPointToScreen(point, mouseEvent.getComponent()); boolean needStopFurtherEventProcessing = false; while (true) { if (popup != null && !popup.isDisposed()) { Window window = ComponentUtil.getWindow(mouseEvent.getComponent()); if (window != null && window != popup.getPopupWindow() && SwingUtilities.isDescendingFrom(window, popup.getPopupWindow())) { return false; } final Component content = popup.getContent(); if (!content.isShowing()) { popup.cancel(); return false; } final Rectangle bounds = new Rectangle(content.getLocationOnScreen(), content.getSize()); if (bounds.contains(point) || !popup.isCancelOnClickOutside()) { return false; } if (!popup.canClose()){ return false; } //click on context menu item if (MenuSelectionManager.defaultManager().getSelectedPath().length > 0) { return false; } if (needStopFurtherEventProcessing(popup, mouseEvent)) { needStopFurtherEventProcessing = true; } popup.cancel(mouseEvent); } if (myStack.isEmpty() || needStopFurtherEventProcessing) { return needStopFurtherEventProcessing; } popup = (AbstractPopup)myStack.peek(); if (popup == null || popup.isDisposed()) { myStack.pop(); } } }