void () { final MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { Rectangle bounds = getBoundsOnScreen(myContent); if (bounds != null) { bounds.x -= 2; bounds.y -= 2; bounds.width += 4; bounds.height += 4; } if (bounds == null || !bounds.contains(e.getLocationOnScreen())) { cancel(); } } }; myContent.addMouseListener(mouseAdapter); Disposer.register(this, () -> myContent.removeMouseListener(mouseAdapter)); myContent.addKeyListener(mySpeedSearch); if (myCancelOnMouseOutCallback != null || myCancelOnWindow) { installMouseOutCanceller(); } ChildFocusWatcher focusWatcher = new ChildFocusWatcher(myContent) { @Override protected void onFocusGained(final FocusEvent event) { setWindowActive(true); } @Override protected void onFocusLost(final FocusEvent event) { setWindowActive(false); } }; Disposer.register(this, focusWatcher); mySpeedSearchPatternField = new SearchTextField(false) { @Override protected void onFieldCleared() { mySpeedSearch.reset(); } }; mySpeedSearchPatternField.getTextEditor().setFocusable(mySpeedSearchAlwaysShown); customizeSearchFieldLook(mySpeedSearchPatternField, mySpeedSearchAlwaysShown); if (mySpeedSearchAlwaysShown) { setHeaderComponent(mySpeedSearchPatternField); } }