TextHitInfo (int x, int y) { if (composedText != null) { Point p = getContentComponent().getLocationOnScreen(); p.x = x - p.x; p.y = y - p.y; int pos = logicalPositionToOffset(xyToLogicalPosition(p)); if (pos >= composedTextStart && pos <= composedTextEnd) { return TextHitInfo.leading(pos - composedTextStart); } } return null; }