javax.swing.text.InternationalFormatter Java Examples

The following examples show how to use javax.swing.text.InternationalFormatter. 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: FormatSelector.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns format's pattern. 
 * 
 * @return format's pattern.
 */
public String getFormat() {
    if (format != null) return format;
    String fmt = null;
    if (formatter instanceof MaskFormatter) {
        fmt = ((MaskFormatter)formatter).getMask();
    } else if (formatter instanceof InternationalFormatter) {
        Format f = ((InternationalFormatter)formatter).getFormat();
        if (f instanceof DecimalFormat) {
            fmt = ((DecimalFormat)f).toPattern();
        } else if (f instanceof SimpleDateFormat) {
            fmt = ((SimpleDateFormat)f).toPattern();
        }
    }
    return fmt;
}
 
Example #2
Source File: AquaSpinnerUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #3
Source File: Test6462562.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #4
Source File: AquaSpinnerUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #5
Source File: Test6462562.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #6
Source File: AquaSpinnerUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #7
Source File: Test6462562.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #8
Source File: AquaSpinnerUI.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #9
Source File: Test6462562.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #10
Source File: AquaSpinnerUI.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #11
Source File: Test6462562.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #12
Source File: AquaSpinnerUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #13
Source File: Test6462562.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #14
Source File: AquaSpinnerUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #15
Source File: Test6462562.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #16
Source File: AquaSpinnerUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #17
Source File: Test6462562.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #18
Source File: AquaSpinnerUI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or -1 if
 * there is no valid calendar field under the selection (or the spinner
 * isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) {
        return -1;
    }

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor) editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) {
        return -1;
    }

    final Format.Field[] fields = ((InternationalFormatter) formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) {
            continue;
        }
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field) element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #19
Source File: Test6462562.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #20
Source File: AquaSpinnerUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #21
Source File: Test6462562.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #22
Source File: AquaSpinnerUI.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #23
Source File: Test6462562.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #24
Source File: AquaSpinnerUI.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #25
Source File: Test6462562.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}
 
Example #26
Source File: AquaSpinnerUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the calendarField under the start of the selection, or
 * -1 if there is no valid calendar field under the selection (or
 * the spinner isn't editing dates.
 */
private int getCalendarField(final JSpinner spinnerComponent) {
    final JComponent editor = spinnerComponent.getEditor();
    if (!(editor instanceof JSpinner.DateEditor)) return -1;

    final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
    final JFormattedTextField ftf = dateEditor.getTextField();
    final int start = ftf.getSelectionStart();
    final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
    if (!(formatter instanceof InternationalFormatter)) return -1;

    final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
    for (final Field element : fields) {
        if (!(element instanceof DateFormat.Field)) continue;
        int calendarField;

        if (element == DateFormat.Field.HOUR1) {
            calendarField = Calendar.HOUR;
        } else {
            calendarField = ((DateFormat.Field)element).getCalendarField();
        }

        if (calendarField != -1) {
            return calendarField;
        }
    }
    return -1;
}
 
Example #27
Source File: Test6462562.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public TestFormattedTextField(InternationalFormatter fmt) {
    super(fmt);
    fmt.setAllowsInvalid(false);
    fmt.setOverwriteMode(true);

    backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
    delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
    insert = getActionMap().get(DefaultEditorKit.insertContentAction);
    dummyEvent = new ActionEvent(this, 0, null);
}