Java TextField getText() returns previous string value
问题 I have a problem with Java Textfield that is when I cover all text in the JTextField and input new text immediately(do not pass backspace) into the JTextField, then I use function getText() I get the previous string not current string. Please help for some solutions. Thanks in advance. 回答1: I just tested the problem you described by adding a keyListener to a JTextField and printing the getText() method's return value to the console. What I found out is that it is always one character behind