Finding the cursor text position in JTextField
问题 Is there a method to return the position of the character in the JTextField. What I mean by that is if I have a JTextField with some values in it. For example, the field contains value ABCDEFJ. The user decides to put the cursor right after the character 'C' to enter a new value. Is there a method to get position where he enters the new character. In this example, that would return a 3. 回答1: JTextField.getCaretPosition() JTextField.setCaretPosition(int pos) 回答2: Try getting use of