JFormattedTextField : Java Glossary
home J words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
JFormattedTextField
A tool in JDK 1.4+ to let you format output and input. JFormattedTextField needs the auxiliary help of MaskFormatter to key phone numbers (250) 361-9093, Zip+4, credit card numbers etc. It needs the help of NumberFormatter and DecimalNumberFormat to deal with numbers. These in turn rely on Documentfilters and NavigationFilters. However, out the box, the fool thing is too dumb to even stop the user from entering alpha characters into a numeric field. Think of it as a complicated Lego set to create usable data entry classes. It works typically by doing a validation when a the component loses focus. I have never heard anyone wax enthusiastically about it. For true keystroke-level validation you may have to write your own from scratch. There is no AWT equivalent, at least in the standard class Library.

You might have more success with AbstractDocument.setDocumentFilter( DocumentFilter ) where you implement a custom DocumentFilter to limit input.

Learning More

Sun’s Javadoc on the JFormattedTextField class : available:
Sun’s Javadoc on the DocumentFilter class : available:

CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.16] Join the Greenpeace cyberactivist community and start making waves.
You are visitor number 11,287.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/jformattedtextfield.html J:\mindprod\jgloss\jformattedtextfield.html