下面列出了javax.swing.text.DefaultFormatter#setOverwriteMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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);
}
/**
* @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;
}
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;
}
/**
* 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;
}