MaxLength on JTextField
1 posts in topic
Flat View  Flat View

Posted By:   Tedy_Colombini
Posted On:   Monday, June 30, 2003 03:26 PM

How can I set a JTextField maximum length?

Re: MaxLength on JTextField

Posted By:   Bahman_Barzideh  
Posted On:   Tuesday, July 1, 2003 05:27 AM

I assume you are trying to limit the length of the data not the width of
the field. If so, I would suggest developing a customized Document for your text field. Take a look at the documentation for JTextField. It contains an example of
customized Document that converts all characters to
upper case before inserting them into the JTextField. Your
version would be similar except that instead of converting to upper case it would ignore the addition any
character (whether typed on the keyboard or pasted into the field) that
would increase the size of the field beyond its maximum length (as set
by you).
About | Sitemap | Contact