I would like to limit the number of characters that are entered in a JTextField in java
I would like to limit the number of characters that are entered in a JTextField in java
You have to use KeyListener
public void keyTyped(KeyEvent e)
{
if (jTextFieldName.getText().length()== limite)
e.consume();
}
limit is the maximum number of characters you want.
e.consume()
removes the characters that are entered when the limit is reached.