Java Code Examples for javax.swing.JFormattedTextField#AbstractFormatter

The following examples show how to use javax.swing.JFormattedTextField#AbstractFormatter . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultFormatterFactory.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Returns either the default formatter, display formatter, editor
 * formatter or null formatter based on the state of the
 * JFormattedTextField.
 *
 * @param source JFormattedTextField requesting
 *               JFormattedTextField.AbstractFormatter
 * @return JFormattedTextField.AbstractFormatter to handle
 *         formatting duties.
 */
public JFormattedTextField.AbstractFormatter getFormatter(
                 JFormattedTextField source) {
    JFormattedTextField.AbstractFormatter format = null;

    if (source == null) {
        return null;
    }
    Object value = source.getValue();

    if (value == null) {
        format = getNullFormatter();
    }
    if (format == null) {
        if (source.hasFocus()) {
            format = getEditFormatter();
        }
        else {
            format = getDisplayFormatter();
        }
        if (format == null) {
            format = getDefaultFormatter();
        }
    }
    return format;
}
 
Example 2
Source File: DefaultFormatterFactory.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a DefaultFormatterFactory with the specified
 * JFormattedTextField.AbstractFormatters.
 *
 * @param defaultFormat JFormattedTextField.AbstractFormatter to be used
 *                      if a more specific
 *                      JFormattedTextField.AbstractFormatter can not be
 *                      found.
 * @param displayFormat JFormattedTextField.AbstractFormatter to be used
 *                      when the JFormattedTextField does not have focus.
 * @param editFormat    JFormattedTextField.AbstractFormatter to be used
 *                      when the JFormattedTextField has focus.
 * @param nullFormat    JFormattedTextField.AbstractFormatter to be used
 *                      when the JFormattedTextField has a null value.
 */
public DefaultFormatterFactory(
              JFormattedTextField.AbstractFormatter defaultFormat,
              JFormattedTextField.AbstractFormatter displayFormat,
              JFormattedTextField.AbstractFormatter editFormat,
              JFormattedTextField.AbstractFormatter nullFormat) {
    this.defaultFormat = defaultFormat;
    this.displayFormat = displayFormat;
    this.editFormat = editFormat;
    this.nullFormat = nullFormat;
}
 
Example 3
Source File: DefaultFormatterFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a DefaultFormatterFactory with the specified
 * JFormattedTextField.AbstractFormatters.
 *
 * @param defaultFormat JFormattedTextField.AbstractFormatter to be used
 *                      if a more specific
 *                      JFormattedTextField.AbstractFormatter can not be
 *                      found.
 * @param displayFormat JFormattedTextField.AbstractFormatter to be used
 *                      when the JFormattedTextField does not have focus.
 * @param editFormat    JFormattedTextField.AbstractFormatter to be used
 *                      when the JFormattedTextField has focus.
 */
public DefaultFormatterFactory(
               JFormattedTextField.AbstractFormatter defaultFormat,
               JFormattedTextField.AbstractFormatter displayFormat,
               JFormattedTextField.AbstractFormatter editFormat) {
    this(defaultFormat, displayFormat, editFormat, null);
}
 
Example 4
Source File: DefaultFormatterFactory.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a <code>DefaultFormatterFactory</code> with the specified
 * <code>JFormattedTextField.AbstractFormatter</code>.
 *
 * @param defaultFormat JFormattedTextField.AbstractFormatter to be used
 *                      if a more specific
 *                      JFormattedTextField.AbstractFormatter can not be
 *                      found.
 */
public DefaultFormatterFactory(JFormattedTextField.
                                   AbstractFormatter defaultFormat) {
    this(defaultFormat, null);
}
 
Example 5
Source File: DefaultFormatterFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the <code>JFormattedTextField.AbstractFormatter</code> to use if
 * the <code>JFormattedTextField</code> is not being edited and either
 * the value is not-null, or the value is null and a null formatter has
 * has not been specified.
 *
 * @param atf JFormattedTextField.AbstractFormatter to use when the
 *            JFormattedTextField does not have focus
 */
public void setDisplayFormatter(JFormattedTextField.AbstractFormatter atf){
    displayFormat = atf;
}
 
Example 6
Source File: DefaultFormatterFactory.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the <code>JFormattedTextField.AbstractFormatter</code> to use
 * if the <code>JFormattedTextField</code> is being edited and either
 * the value is not-null, or the value is null and a null formatter has
 * has not been specified.
 *
 * @return JFormattedTextField.AbstractFormatter to use when the
 *         component has focus
 */
public JFormattedTextField.AbstractFormatter getEditFormatter() {
    return editFormat;
}
 
Example 7
Source File: DefaultFormatterFactory.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the <code>JFormattedTextField.AbstractFormatter</code> to use
 * if the <code>JFormattedTextField</code> is not being edited and either
 * the value is not-null, or the value is null and a null formatter has
 * has not been specified.
 *
 * @return JFormattedTextField.AbstractFormatter to use when the
 *         JFormattedTextField does not have focus
 */
public JFormattedTextField.AbstractFormatter getDisplayFormatter() {
    return displayFormat;
}
 
Example 8
Source File: DefaultFormatterFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the <code>JFormattedTextField.AbstractFormatter</code> to use if
 * the <code>JFormattedTextField</code> is being edited and either
 * the value is not-null, or the value is null and a null formatter has
 * has not been specified.
 *
 * @param atf JFormattedTextField.AbstractFormatter to use when the
 *            component has focus
 */
public void setEditFormatter(JFormattedTextField.AbstractFormatter atf) {
    editFormat = atf;
}
 
Example 9
Source File: DefaultFormatterFactory.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the formatter to use if the value is null.
 *
 * @return JFormattedTextField.AbstractFormatter to use when the value is
 *         null
 */
public JFormattedTextField.AbstractFormatter getNullFormatter() {
    return nullFormat;
}
 
Example 10
Source File: DefaultFormatterFactory.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a <code>DefaultFormatterFactory</code> with the specified
 * <code>JFormattedTextField.AbstractFormatter</code>s.
 *
 * @param defaultFormat JFormattedTextField.AbstractFormatter to be used
 *                      if a more specific
 *                      JFormattedTextField.AbstractFormatter can not be
 *                      found.
 * @param displayFormat JFormattedTextField.AbstractFormatter to be used
 *                      when the JFormattedTextField does not have focus.
 */
public DefaultFormatterFactory(
                 JFormattedTextField.AbstractFormatter defaultFormat,
                 JFormattedTextField.AbstractFormatter displayFormat) {
    this(defaultFormat, displayFormat, null);
}
 
Example 11
Source File: DefaultFormatterFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the formatter to use if the value is null.
 *
 * @return JFormattedTextField.AbstractFormatter to use when the value is
 *         null
 */
public JFormattedTextField.AbstractFormatter getNullFormatter() {
    return nullFormat;
}
 
Example 12
Source File: DefaultFormatterFactory.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a <code>DefaultFormatterFactory</code> with the specified
 * <code>JFormattedTextField.AbstractFormatter</code>.
 *
 * @param defaultFormat JFormattedTextField.AbstractFormatter to be used
 *                      if a more specific
 *                      JFormattedTextField.AbstractFormatter can not be
 *                      found.
 */
public DefaultFormatterFactory(JFormattedTextField.
                                   AbstractFormatter defaultFormat) {
    this(defaultFormat, null);
}
 
Example 13
Source File: DefaultFormatterFactory.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the formatter to use if the value of the JFormattedTextField is
 * null.
 *
 * @param atf JFormattedTextField.AbstractFormatter to use when
 * the value of the JFormattedTextField is null.
 */
public void setNullFormatter(JFormattedTextField.AbstractFormatter atf) {
    nullFormat = atf;
}
 
Example 14
Source File: DefaultFormatterFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a <code>DefaultFormatterFactory</code> with the specified
 * <code>JFormattedTextField.AbstractFormatter</code>s.
 *
 * @param defaultFormat JFormattedTextField.AbstractFormatter to be used
 *                      if a more specific
 *                      JFormattedTextField.AbstractFormatter can not be
 *                      found.
 * @param displayFormat JFormattedTextField.AbstractFormatter to be used
 *                      when the JFormattedTextField does not have focus.
 */
public DefaultFormatterFactory(
                 JFormattedTextField.AbstractFormatter defaultFormat,
                 JFormattedTextField.AbstractFormatter displayFormat) {
    this(defaultFormat, displayFormat, null);
}
 
Example 15
Source File: DefaultFormatterFactory.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the <code>JFormattedTextField.AbstractFormatter</code> to use if
 * the <code>JFormattedTextField</code> is being edited and either
 * the value is not-null, or the value is null and a null formatter has
 * has not been specified.
 *
 * @param atf JFormattedTextField.AbstractFormatter to use when the
 *            component has focus
 */
public void setEditFormatter(JFormattedTextField.AbstractFormatter atf) {
    editFormat = atf;
}
 
Example 16
Source File: DefaultFormatterFactory.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the <code>JFormattedTextField.AbstractFormatter</code> to use
 * if the <code>JFormattedTextField</code> is not being edited and either
 * the value is not-null, or the value is null and a null formatter has
 * has not been specified.
 *
 * @return JFormattedTextField.AbstractFormatter to use when the
 *         JFormattedTextField does not have focus
 */
public JFormattedTextField.AbstractFormatter getDisplayFormatter() {
    return displayFormat;
}
 
Example 17
Source File: DefaultFormatterFactory.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a <code>DefaultFormatterFactory</code> with the specified
 * <code>JFormattedTextField.AbstractFormatter</code>.
 *
 * @param defaultFormat JFormattedTextField.AbstractFormatter to be used
 *                      if a more specific
 *                      JFormattedTextField.AbstractFormatter can not be
 *                      found.
 */
public DefaultFormatterFactory(JFormattedTextField.
                                   AbstractFormatter defaultFormat) {
    this(defaultFormat, null);
}
 
Example 18
Source File: DefaultFormatterFactory.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a <code>DefaultFormatterFactory</code> with the specified
 * <code>JFormattedTextField.AbstractFormatter</code>s.
 *
 * @param defaultFormat JFormattedTextField.AbstractFormatter to be used
 *                      if a more specific
 *                      JFormattedTextField.AbstractFormatter can not be
 *                      found.
 * @param displayFormat JFormattedTextField.AbstractFormatter to be used
 *                      when the JFormattedTextField does not have focus.
 */
public DefaultFormatterFactory(
                 JFormattedTextField.AbstractFormatter defaultFormat,
                 JFormattedTextField.AbstractFormatter displayFormat) {
    this(defaultFormat, displayFormat, null);
}
 
Example 19
Source File: DefaultFormatterFactory.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the <code>JFormattedTextField.AbstractFormatter</code> to use
 * if the <code>JFormattedTextField</code> is not being edited and either
 * the value is not-null, or the value is null and a null formatter has
 * has not been specified.
 *
 * @return JFormattedTextField.AbstractFormatter to use when the
 *         JFormattedTextField does not have focus
 */
public JFormattedTextField.AbstractFormatter getDisplayFormatter() {
    return displayFormat;
}
 
Example 20
Source File: DefaultFormatterFactory.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the <code>JFormattedTextField.AbstractFormatter</code> to use as
 * a last resort, eg in case a display, edit or null
 * <code>JFormattedTextField.AbstractFormatter</code> has not been
 * specified.
 *
 * @param atf JFormattedTextField.AbstractFormatter used if a more
 *            specific is not specified
 */
public void setDefaultFormatter(JFormattedTextField.AbstractFormatter atf){
    defaultFormat = atf;
}