Receive cursor position in a JTextField



Hi,

I have a JTextField, and I have text in it. For example the string “example text”.
The user can position the curser in the JTextField for example between p and l.
My problem: I need a method that gives me the position of the cursor in the JTextField. For the example the method should return 5, because the cursor is positioned behind the 5th letter (the p).
How should such a method look like? Or how in principle can I do this?


Thanks!
.



Relevant Pages