boolean (JLayeredPane pane, JComponent component, RelativePoint desiredLocation, HintHint hintHint) { if (hintHint.isAwtTooltip()) { Dimension size = component.getPreferredSize(); Dimension paneSize = pane.getSize(); Point target = desiredLocation.getPointOn(pane).getPoint(); Balloon.Position pos = hintHint.getPreferredPosition(); int pointer = BalloonImpl.getPointerLength(pos, false) + BalloonImpl.getNormalInset(); if (pos == Balloon.Position.above || pos == Balloon.Position.below) { boolean heightFit = target.y - size.height - pointer > 0 || target.y + size.height + pointer < paneSize.height; return heightFit && size.width + pointer < paneSize.width; } else { boolean widthFit = target.x - size.width - pointer > 0 || target.x + size.width + pointer < paneSize.width; return widthFit && size.height + pointer < paneSize.height; } } else { final Rectangle lpRect = new Rectangle(pane.getLocationOnScreen().x, pane.getLocationOnScreen().y, pane.getWidth(), pane.getHeight()); Rectangle componentRect = new Rectangle(desiredLocation.getScreenPoint().x, desiredLocation.getScreenPoint().y, component.getPreferredSize().width, component.getPreferredSize().height); return lpRect.contains(componentRect); } }