📅  最后修改于: 2022-03-11 14:57:57.049000             🧑  作者: Mango
textField = new JTextField();
textField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if (txtGuess.getText().length() >= 3 ) // limit to 3 characters
e.consume();
}
});