There is no way to directly set a JTextField‘s maximum character length. The only way for you to do that is to create your own class that inherits the PlainDocument class, instantiate an object of that class and call the JTextField method setDocument().

Below is the source for the custom made MaxLengthTextDocument class.

Related Posts Plugin for WordPress, Blogger...