Class DateFormatter
java.lang.Object
javax.swing.JFormattedTextField.AbstractFormatter
javax.swing.text.DefaultFormatter
javax.swing.text.InternationalFormatter
javax.swing.text.DateFormatter
- All Implemented Interfaces:
Serializable, Cloneable
DateFormatter is an
InternationalFormatter that does its
formatting by way of an instance of java.text.DateFormat.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see XMLEncoder.
- Since:
- 1.4
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionThis is shorthand fornew DateFormatter(DateFormat.getDateInstance()).DateFormatter(DateFormat format) Returns a DateFormatter configured with the specifiedFormatinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetFormat(DateFormat format) Sets the format that dictates the legal values that can be edited and displayed.Methods declared in class InternationalFormatter
clone, getActions, getFields, getFormat, getMaximum, getMinimum, install, setFormat, setMaximum, setMinimum, stringToValue, valueToStringModifier and TypeMethodDescriptionclone()Creates a copy of the DefaultFormatter.protected Action[]IfgetSupportsIncrementreturns true, this returns two Actions suitable for incrementing/decrementing the value.getFields(int offset) Returns theFormat.Fieldconstants associated with the text atoffset.Returns the format that dictates the legal values that can be edited and displayed.Comparable<?> Returns the maximum permissible value.Comparable<?> Returns the minimum permissible value.voidInstalls theDefaultFormatteronto a particularJFormattedTextField.voidSets the format that dictates the legal values that can be edited and displayed.voidsetMaximum(Comparable<?> max) Sets the maximum permissible value.voidsetMinimum(Comparable<?> minimum) Sets the minimum permissible value.stringToValue(String text) Returns theObjectrepresentation of theStringtext.valueToString(Object value) Returns a String representation of the Objectvalue.Methods declared in class DefaultFormatter
getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClassModifier and TypeMethodDescriptionbooleanReturns whether or not the value being edited is allowed to be invalid for a length of time.booleanReturns when edits are published back to theJFormattedTextField.protected DocumentFilterReturns theDocumentFilterused to restrict the characters that can be input into theJFormattedTextField.protected NavigationFilterReturns theNavigationFilterused to restrict where the cursor can be placed.booleanReturns the behavior when inserting characters.Class<?> Returns that class that is used to create new Objects.voidsetAllowsInvalid(boolean allowsInvalid) Sets whether or not the value being edited is allowed to be invalid for a length of time (that is,stringToValuethrows aParseException).voidsetCommitsOnValidEdit(boolean commit) Sets when edits are published back to theJFormattedTextField.voidsetOverwriteMode(boolean overwriteMode) Configures the behavior when inserting characters.voidsetValueClass(Class<?> valueClass) Sets that class that is used to create new Objects.Methods declared in class JFormattedTextField.AbstractFormatter
getFormattedTextField, invalidEdit, setEditValid, uninstallModifier and TypeMethodDescriptionprotected JFormattedTextFieldReturns the currentJFormattedTextFieldtheAbstractFormatteris installed on.protected voidThis should be invoked when the user types an invalid character.protected voidsetEditValid(boolean valid) Invoke this to update theeditValidproperty of theJFormattedTextField.voidUninstalls any state theAbstractFormattermay have installed on theJFormattedTextField.Methods declared in class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionbooleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
DateFormatter
public DateFormatter()This is shorthand fornew DateFormatter(DateFormat.getDateInstance()). -
DateFormatter
Returns a DateFormatter configured with the specifiedFormatinstance.- Parameters:
format- Format used to dictate legal values
-
-
Method Details
-
setFormat
Sets the format that dictates the legal values that can be edited and displayed.If you have used the nullary constructor the value of this property will be determined for the current locale by way of the
Dateformat.getDateInstance()method.- Parameters:
format- DateFormat instance used for converting from/to Strings
-