DefaultFormatterFactory (Java Platform SE 8 ) (original) (raw)


public class DefaultFormatterFactory
extends JFormattedTextField.AbstractFormatterFactory
implements Serializable
An implementation ofJFormattedTextField.AbstractFormatterFactory.DefaultFormatterFactory allows specifying a number of different JFormattedTextField.AbstractFormatters that are to be used. The most important one is the default one (setDefaultFormatter). The default formatter will be used if a more specific formatter could not be found. The following process is used to determine the appropriate formatter to use.

  1. Is the passed in value null? Use the null formatter.
  2. Does the JFormattedTextField have focus? Use the edit formatter.
  3. Otherwise, use the display formatter.
  4. If a non-null AbstractFormatter has not been found, use the default formatter.
    The following code shows how to configure aJFormattedTextField with twoJFormattedTextField.AbstractFormatters, one for display and one for editing.
    JFormattedTextField.AbstractFormatter editFormatter = ...;
    JFormattedTextField.AbstractFormatter displayFormatter = ...;
    DefaultFormatterFactory factory = new DefaultFormatterFactory(
    displayFormatter, displayFormatter, editFormatter);

JFormattedTextField tf = new JFormattedTextField(factory);

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:
JFormattedTextField

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.