void (Component c, MouseEvent me, boolean now) { if (!(c instanceof JComponent comp)) return; Window wnd = SwingUtilities.getWindowAncestor(comp); if (wnd == null) return; if (!wnd.isActive()) { if (JBPopupFactory.getInstance().isChildPopupFocused(wnd)) return; } if (!isTooltipDefined(comp, me)) { hideCurrent(null); return; } boolean centerDefault = Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT)); boolean centerStrict = Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_STRICT)); int shift = centerStrict ? 0 : centerDefault ? 4 : 0; // Balloon may appear exactly above useful content, such behavior is rather annoying. Rectangle rowBounds = null; if (c instanceof JTree) { TreePath path = ((JTree)c).getClosestPathForLocation(me.getX(), me.getY()); if (path != null) { rowBounds = ((JTree)c).getPathBounds(path); } } else if (c instanceof JList) { int row = ((JList<?>)c).locationToIndex(me.getPoint()); if (row > -1) { rowBounds = ((JList<?>)c).getCellBounds(row, row); } } if (rowBounds != null && rowBounds.y + 4 < me.getY()) { shift += me.getY() - rowBounds.y - 4; } showTooltipForEvent(comp, me, centerStrict || centerDefault, shift, -shift, -shift, now); }