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 (composedTextRange.containsOffset(pos)) { return TextHitInfo.leading(pos - composedTextRange.getStartOffset()); } } return null; }