API Overview API Index Package Overview Direct link to this page
JDK 1.6
  javax.swing.text. MaskFormatter View Source
Author(s)
Since
1.4
Version
1.13 11/17/05
Serial
Hierarchy
 Object
      JFormattedTextField.AbstractFormatter
          DefaultFormatter
              MaskFormatter
Implements
Subclasses
Description
public class MaskFormatter
  MaskFormatter is used to format and edit strings.
See also:   
Constructors
public MaskFormatter ()
Creates a MaskFormatter with no mask.
public MaskFormatter (String mask) throws ParseException
  Creates a MaskFormatter with the specified mask.
Methods
Hide/Show inherited methods
pack-private boolean canReplace (ReplaceHolder rh) [Overrides DefaultFormatter]
  This method does the following (assuming !getAllowsInvalid()): iterate over the max of the deleted region or the text length, for each character: If it is valid (matches the mask at the particular position, or matches the literal character at the position), allow it Else if the position identifies a literal character, add it.
public Object clone () throws CloneNotSupportedException [Inherited From DefaultFormatter]
  Creates a copy of the DefaultFormatter.
pack-private void commitEdit () throws ParseException [Inherited From DefaultFormatter]
Invokes commitEdit on the JFormattedTextField.
protected Action getActions () [Inherited From JFormattedTextField.AbstractFormatter]
  Subclass and override if you wish to provide a custom set of Actions.
public boolean getAllowsInvalid () [Inherited From DefaultFormatter]
  Returns whether or not the value being edited is allowed to be invalid for a length of time.
public boolean getCommitsOnValidEdit () [Inherited From DefaultFormatter]
  Returns when edits are published back to the JFormattedTextField.
protected DocumentFilter getDocumentFilter () [Inherited From DefaultFormatter]
  Returns the DocumentFilter used to restrict the characters that can be input into the JFormattedTextField.
protected JFormattedTextField getFormattedTextField () [Inherited From JFormattedTextField.AbstractFormatter]
  Returns the current JFormattedTextField the AbstractFormatter is installed on.
pack-private int getInitialVisualPosition () [Inherited From DefaultFormatter]
  Returns the initial location to position the cursor at.
public String getInvalidCharacters ()
  Returns the characters that are not valid for input.
public String getMask ()
  Returns the formatting mask.
protected NavigationFilter getNavigationFilter () [Inherited From DefaultFormatter]
  Returns the NavigationFilter used to restrict where the cursor can be placed.
pack-private int getNextCursorPosition (int offset, int direction) [Inherited From DefaultFormatter]
  Returns the next cursor position from offset by incrementing direction.
pack-private int getNextVisualPositionFrom (JTextComponent text, int pos, Bias bias, int direction, Bias biasRet) throws BadLocationException [Inherited From DefaultFormatter]
Finds the next navigatable character.
public boolean getOverwriteMode () [Inherited From DefaultFormatter]
  Returns the behavior when inserting characters.
public String getPlaceholder ()
  Returns the String to use if the value does not completely fill in the mask.
public char getPlaceholderCharacter ()
  Returns the character to use in place of characters that are not present in the value, ie the user must fill them in.
pack-private ReplaceHolder getReplaceHolder (FilterBypass fb, int offset, int length, String text, AttributeSet attrs) [Inherited From DefaultFormatter]
Returns the ReplaceHolder to track the replace of the specified text.
pack-private String getReplaceString (int offset, int deleteLength, String replaceString) [Inherited From DefaultFormatter]
A convenience methods to return the result of deleting deleteLength characters at offset and inserting replaceString at offset in the current text field.
public String getValidCharacters ()
  Returns the valid characters that can be input.
public Class<Object> getValueClass () [Inherited From DefaultFormatter]
  Returns that class that is used to create new Objects.
public boolean getValueContainsLiteralCharacters ()
  Returns true if stringToValue should return literal characters in the mask.
public void install (JFormattedTextField ftf) [Overrides DefaultFormatter]
  Installs the DefaultFormatter onto a particular JFormattedTextField.
protected void invalidEdit () [Inherited From JFormattedTextField.AbstractFormatter]
  This should be invoked when the user types an invalid character.
pack-private boolean isLegalInsertText (String text) [Inherited From DefaultFormatter]
  Returns true if the text in text can be inserted.
pack-private boolean isNavigatable (int offset) [Overrides DefaultFormatter]
Returns true if the MaskFormatter allows invalid, or the offset is less than the max length and the character at offset is a literal.
pack-private boolean isValidEdit (ReplaceHolder rh) [Overrides DefaultFormatter]
pack-private void moveDot (FilterBypass fb, int dot, Bias bias) [Inherited From DefaultFormatter]
NavigationFilter method, subclasses that wish finer control should override this.
pack-private void positionCursorAtInitialLocation () [Inherited From DefaultFormatter]
Positions the cursor at the initial location.
pack-private boolean replace (ReplaceHolder rh) throws BadLocationException [Inherited From DefaultFormatter]
  If the edit described by rh is legal, this will return true, commit the edit (if necessary) and update the cursor position.
pack-private void replace (FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException [Inherited From DefaultFormatter]
DocumentFilter method, funnels into replace.
pack-private void repositionCursor (int offset, int direction) [Inherited From DefaultFormatter]
Resets the cursor by using getNextCursorPosition.
public void setAllowsInvalid (boolean allowsInvalid) [Inherited From DefaultFormatter]
  Sets whether or not the value being edited is allowed to be invalid for a length of time (that is, stringToValue throws a ParseException).
public void setCommitsOnValidEdit (boolean commit) [Inherited From DefaultFormatter]
  Sets when edits are published back to the JFormattedTextField.
pack-private void setDot (FilterBypass fb, int dot, Bias bias) [Inherited From DefaultFormatter]
NavigationFilter method, subclasses that wish finer control should override this.
protected void setEditValid (boolean valid) [Inherited From JFormattedTextField.AbstractFormatter]
  Invoke this to update the editValid property of the JFormattedTextField.
public void setInvalidCharacters (String invalidCharacters)
  Allows for further restricting of the characters that can be input.
public void setMask (String mask) throws ParseException
  Sets the mask dictating the legal characters.
public void setOverwriteMode (boolean overwriteMode) [Inherited From DefaultFormatter]
  Configures the behavior when inserting characters.
public void setPlaceholder (String placeholder)
  Sets the string to use if the value does not completely fill in the mask.
public void setPlaceholderCharacter (char placeholder)
  Sets the character to use in place of characters that are not present in the value, ie the user must fill them in.
public void setValidCharacters (String validCharacters)
  Allows for further restricting of the characters that can be input.
public void setValueClass (Class<Object> valueClass) [Inherited From DefaultFormatter]
  Sets that class that is used to create new Objects.
public void setValueContainsLiteralCharacters (boolean containsLiteralChars)
  If true, the returned value and set value will also contain the literal characters in mask.
public Object stringToValue (String value) throws ParseException [Overrides DefaultFormatter] [Specified in JFormattedTextField.AbstractFormatter]
  Parses the text, returning the appropriate Object representation of the String value.
public void uninstall () [Inherited From JFormattedTextField.AbstractFormatter]
  Uninstalls any state the AbstractFormatter may have installed on the JFormattedTextField.
pack-private void updateValue () [Inherited From DefaultFormatter]
Pushes the value to the JFormattedTextField if the current value is valid and invokes setEditValid based on the validity of the value.
pack-private void updateValue (Object value) [Inherited From DefaultFormatter]
  Pushes the value to the editor if we are to commit on edits.
public String valueToString (Object value) throws ParseException [Overrides DefaultFormatter] [Specified in JFormattedTextField.AbstractFormatter]
  Returns a String representation of the Object value based on the mask.
Fields
Hide/Show inherited fields
pack-privatetransient ReplaceHolder replaceHolder [Inherited From DefaultFormatter]
Used during replace to track the region to replace.
Nested Classes
  DefaultFormatter.ReplaceHolder
ReplaceHolder is used to track where insert/remove/replace is going to happen.
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar