Search code examples
javaswingjtextfieldpointcaret

Java - How to get character to the left of caret point (JTextField)


I want to get the character to the left of the insertion point in the JTextField.

I already have this: final int pos = input.getCaretPosition();

How do I get the character to the left and right of this int?


Solution

  • what about textField.getText().charAt(pos - 1) ?