JFormattedTextField : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

JFormattedTextField
A tool in Java version 1.4 or later 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 (Advanced Windowing Toolkit) 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

Oracle’s Javadoc on JFormattedTextField class : available:
Oracle’s Javadoc on DocumentFilter class : available:

This page is posted
on the web at:

http://mindprod.com/jgloss/jformattedtextfield.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\jformattedtextfield.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[98.84.18.52]
You are visitor number