• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Setting maxlength in Swing

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi team,

How can we set maxlength of a JTextField? Could someone please give suggestions in this regard?

Thanks in advance,
Jenny
 
Ranch Hand
Posts: 693
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on validating data too.

I'm trying the class "InputVerifier". It looks promising and it seems as general as I would ever need.

http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/InputVerifier.html

Kaydell
 
Kaydell Leavitt
Ranch Hand
Posts: 693
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, it seems that I need to use both a DocumentFilter and an InputVerifier.

I plan to have DocumentFilter to disallow characters that couldn't possibly be right, but allow partial entry that could be right if completed correctly.

I plan to have InputVerifiers to validate the input when the user is done such as when they try to go to another field in the JFrame.

Kaydell
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!