Java Code Examples for javax.swing.text.DefaultFormatter#setOverwriteMode()

The following examples show how to use javax.swing.text.DefaultFormatter#setOverwriteMode() . 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: ReactionBonusEditor.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected void rebuildSelf(FlexGrid grid, FlexRow right) {
    ReactionBonus bonus = (ReactionBonus) getFeature();
    FlexRow       row   = new FlexRow();
    row.add(addChangeBaseTypeCombo());
    LeveledAmount amount = bonus.getAmount();
    row.add(addLeveledAmountField(amount, -99999, 99999));
    row.add(addLeveledAmountCombo(amount, false));
    row.add(new FlexSpacer(0, 0, true, false));
    grid.add(row, 0, 0);

    row = new FlexRow();
    row.setInsets(new Insets(0, 20, 0, 0));

    DefaultFormatter formatter = new DefaultFormatter();
    formatter.setOverwriteMode(false);
    mSituationField = new EditorField(new DefaultFormatterFactory(formatter), this, SwingConstants.LEFT, bonus.getSituation(), null);
    add(mSituationField);
    row.add(mSituationField);
    row.add(new FlexSpacer(0, 0, true, false));
    grid.add(row, 1, 0);
}
 
Example 2
Source File: EditorPanel.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * @param compare The current string compare object.
 * @return The field that allows a string comparison to be changed.
 */
protected EditorField addStringCompareField(StringCriteria compare) {
    DefaultFormatter formatter = new DefaultFormatter();
    formatter.setOverwriteMode(false);
    EditorField field = new EditorField(new DefaultFormatterFactory(formatter), this, SwingConstants.LEFT, compare.getQualifier(), null);
    field.putClientProperty(StringCriteria.class, compare);
    add(field);
    return field;
}
 
Example 3
Source File: AdvantageEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private EditorField createField(String text, String prototype, String tooltip) {
    DefaultFormatter formatter = new DefaultFormatter();
    formatter.setOverwriteMode(false);
    EditorField field = new EditorField(new DefaultFormatterFactory(formatter), this, SwingConstants.LEFT, text, prototype, tooltip);
    field.setEnabled(mIsEditable);
    add(field);
    return field;
}
 
Example 4
Source File: WeaponEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Creates a new text field.
 *
 * @param protoValue A prototype value. If not {@code null}, will be used to set the only size
 *                   the field can have.
 * @param tooltip    The tooltip to set on the field.
 * @return The newly created field.
 */
protected EditorField createTextField(String protoValue, String tooltip) {
    DefaultFormatter formatter = new DefaultFormatter();
    formatter.setOverwriteMode(false);
    EditorField field = new EditorField(new DefaultFormatterFactory(formatter), this, SwingConstants.LEFT, "", protoValue, tooltip);
    if (protoValue != null) {
        UIUtilities.setToPreferredSizeOnly(field);
    }
    return field;
}