Hi all, i want to limit the number of characters a JTextField can accept to maximum of 6 characters so that any characters typed by the user beyond these characters not shown in TextField. How can i petrform that.
In future, please start a new thread for your questions. Also, this particular thread is 6 years old.
The InputVerifier is not the correct solution. InputVerifier only ensures that the component will not loose focus in case the validation fails. It does not enforce the input conditions as you want.
This question comes up quite a few times and has been answered before. Search the forums.
The ranch Swing FAQ also has an article on numeric text fields with sample code. You can adapt the code to suit your requirements.