Convert caret position to mouse position


How can convert a "caret position" (Column,Line) to a mouse position (pixels) ?

I know how to retrieve the caret :

final Editor vEditor = prEvent.getData(CommonDataKeys.EDITOR);
assert vEditor != null;

Caret vCaret = vEditor.getCaretModel().getPrimaryCaret();
LogicalPosition vPosition=vCaret.getLogicalPosition();
1 comment
Comment actions Permalink

You can use Editor.logicalPositionToXY() method. See also Editor.getScrollingModel().getVerticalScrollOffset() to adjust for scrollbar position.


Please sign in to leave a comment.