|      | Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form | 
 
In release 1.4,JFormattedTextFieldwas introduced. Formatted text fields provide a way for developers to specify the legal set of characters that can be entered into a text component.
Version Note: Before 1.4, text field formatting required more effort. See Creating a Validated Text Fieldfor a full example.
[PENDING: One day, this page will discuss formatted text fields. For now, it only has links to API. You can find more information about using the API in Formatted Text Fields
, which is part of the J2SE v 1.4 release notes.]
The following tables list some of the commonly used API for using formatted text fields.
Classes Related to Formatted Text Fields Method Purpose JFormattedTextFieldSubclass of JTextFieldthat supports formatting arbitrary values.JFormattedTextField.AbstractFormatterThe superclass of all formatters for JFormattedTextField. A formatter enforces editing policies and navigation policies, handles string-to-object conversions, and manipulates theJFormattedTextFieldas necessary to enforce the desired policy.JFormattedTextField.AbstractFormatterFactoryThe superclass of all formatter factories. Each JFormattedTextFielduses a formatter factory to obtain the formatter that best corresponds to the text field's state.DefaultFormatterFactoryThe formatter factory normally used. Dishes out formatters based on details such as the passed-in parameters and focus state. DefaultFormatterSubclass of JFormattedTextField.AbstractFormatterthat formats arbitrary objects using thetoStringmethod.MaskFormatterSubclass of DefaultFormatterthat formats and edits strings using a specified character mask. (For example, 7-digit phone numbers can be specified using "###-####".)InternationalFormatterSubclass of DefaultFormatterthat uses an instance ofjava.text.Formatto handle conversion to and from aString.NumberFormatterSubclass of InternationalFormatterthat supports number formats using an instance ofNumberFormat.DateFormatterSubclass of InternationalFormatterthat supports date formats using an instance ofDateFormat.
JFormattedTextField Methods Method Purpose JFormattedTextField()
JFormattedTextField(Object)
JFormattedTextField(Format)
JFormattedTextField(JFormattedTextField.AbstractFormatter)
JFormattedTextField(JFormattedTextField.AbstractFormatterFactory)
JFormattedTextField(JFormattedTextField.AbstractFormatterFactory, Object)Create a new formatted text field. void setValue(Object)
Object getValue()Set or get the value of the formatted text field. You must cast the return type based on how the JFormattedTextFieldhas been configured.
DefaultFormatter Options Method Purpose void setCommitsOnValidEdit(boolean)
boolean getCommitsOnValidEdit()Set or get when edits are pushed back to the JFormattedTextFieldIftrue,commitEditis invoked after every valid edit.void setOverwriteMode(boolean)
boolean getOverwriteMode()Set or get the the behavior when inserting characters. If true(the default), new characters overwrite existing characters in the model as they are inserted.void setAllowsInvalid(boolean)
boolean getAllowsInvalid()Set or get whether the value being edited is allowed to be invalid for a length of time. It is often convenient to allow the user to enter invalid values until a commit is attempted. If true,commitEditis invoked after every valid edit.
 
|      | Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form | 
Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.