Check out example codes for "get cursor position in textarea java". It will help you in understanding the concepts better.

Code Example 1

int currentCaretPosition = textPane.getCaretPosition();

Learn ReactJs, React Native from akashmittal.com