Java Code Examples for javax.swing.text.DefaultFormatterFactory

The following examples show how to use javax.swing.text.DefaultFormatterFactory. These examples are extracted from open source projects. 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
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 2
Source Project: pcgen   Source File: SkillInfoTab.java    License: GNU Lesser General Public License v2.1 7 votes vote down vote up
private SkillRankSpinnerEditor(SkillRankSpinnerModel model)
{
	super(model);
	this.model = model;

	DefaultEditor editor = new DefaultEditor(spinner);
	NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.#")); //$NON-NLS-1$
	formatter.setValueClass(Float.class);
	DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter);

	JFormattedTextField ftf = editor.getTextField();
	ftf.setEditable(true);
	ftf.setFormatterFactory(factory);
	ftf.setHorizontalAlignment(SwingConstants.RIGHT);

	spinner.setEditor(editor);
}
 
Example 3
Source Project: gcs   Source File: FeatureEditor.java    License: Mozilla Public License 2.0 6 votes vote down vote up
/**
 * @param amt The current {@link LeveledAmount}.
 * @param min The minimum value to allow.
 * @param max The maximum value to allow.
 * @return The {@link EditorField} that allows a {@link LeveledAmount} to be changed.
 */
protected EditorField addLeveledAmountField(LeveledAmount amt, int min, int max) {
    AbstractFormatter formatter;
    Object            value;
    Object            prototype;
    if (amt.isIntegerOnly()) {
        formatter = new IntegerFormatter(min, max, true);
        value = Integer.valueOf(amt.getIntegerAmount());
        prototype = Integer.valueOf(max);
    } else {
        formatter = new DoubleFormatter(min, max, true);
        value = Double.valueOf(amt.getAmount());
        prototype = Double.valueOf(max + 0.25);
    }
    EditorField field = new EditorField(new DefaultFormatterFactory(formatter), this, SwingConstants.LEFT, value, prototype, null);
    field.putClientProperty(LeveledAmount.class, amt);
    UIUtilities.setToPreferredSizeOnly(field);
    add(field);
    return field;
}
 
Example 4
Source Project: gcs   Source File: ReactionBonusEditor.java    License: 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 5
@Override
protected void rebuildSelf(FlexGrid grid, FlexRow right) {
    ContainedWeightReduction feature = (ContainedWeightReduction) getFeature();
    FlexRow                  row     = new FlexRow();
    row.add(addChangeBaseTypeCombo());
    EditorField field = new EditorField(new DefaultFormatterFactory(new WeightReductionFormatter()), (event) -> {
        EditorField source = (EditorField) event.getSource();
        if ("value".equals(event.getPropertyName())) {
            feature.setValue(source.getValue());
            notifyActionListeners();
        }
    }, SwingConstants.LEFT, feature.getValue(), new WeightValue(new Fixed6(999999999), getRow().getDataFile().defaultWeightUnits()), I18n.Text("Enter a weight or percentage, e.g. \"2 lb\" or \"5%\"."));
    UIUtilities.setToPreferredSizeOnly(field);
    add(field);
    row.add(field);
    row.add(new FlexSpacer(0, 0, true, false));
    grid.add(row, 0, 0);
}
 
Example 6
public NumberPropertyEditor(Class type) {
  if (!Number.class.isAssignableFrom(type)) {
    throw new IllegalArgumentException("type must be a subclass of Number");
  }

  editor = new JFormattedTextField();
  this.type = type;
  ((JFormattedTextField)editor).setValue(getDefaultValue());
  ((JFormattedTextField)editor).setBorder(LookAndFeelTweaks.EMPTY_BORDER);

  // use a custom formatter to have numbers with up to 64 decimals
  NumberFormat format = NumberConverters.getDefaultFormat();

  ((JFormattedTextField) editor).setFormatterFactory(
      new DefaultFormatterFactory(new NumberFormatter(format))
  );
}
 
Example 7
Source Project: pcgen   Source File: SkillInfoTab.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private SkillRankSpinnerEditor(SkillRankSpinnerModel model)
{
	super(model);
	this.model = model;

	DefaultEditor editor = new DefaultEditor(spinner);
	NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.#")); //$NON-NLS-1$
	formatter.setValueClass(Float.class);
	DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter);

	JFormattedTextField ftf = editor.getTextField();
	ftf.setEditable(true);
	ftf.setFormatterFactory(factory);
	ftf.setHorizontalAlignment(SwingConstants.RIGHT);

	spinner.setEditor(editor);
}
 
Example 8
public NumberPropertyEditor(Class type) {
  if (!Number.class.isAssignableFrom(type)) {
    throw new IllegalArgumentException("type must be a subclass of Number");
  }

  editor = new JFormattedTextField();
  this.type = type;
  ((JFormattedTextField)editor).setValue(getDefaultValue());
  ((JFormattedTextField)editor).setBorder(LookAndFeelTweaks.EMPTY_BORDER);

  // use a custom formatter to have numbers with up to 64 decimals
  NumberFormat format = NumberConverters.getDefaultFormat();

  ((JFormattedTextField) editor).setFormatterFactory(
      new DefaultFormatterFactory(new NumberFormatter(format))
  );
}
 
Example 9
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 6 votes vote down vote up
protected LocalDateTimeEditor(JSpinner spinner, String dateFormatPattern) {
  super(spinner);
  if (!(spinner.getModel() instanceof SpinnerLocalDateTimeModel)) {
    throw new IllegalArgumentException("model not a SpinnerLocalDateTimeModel");
  }
  dateTimeFormatter = DateTimeFormatter.ofPattern(dateFormatPattern);
  model = (SpinnerLocalDateTimeModel) spinner.getModel();
  DefaultFormatter formatter = new LocalDateTimeFormatter();

  EventQueue.invokeLater(() -> {
    formatter.setValueClass(LocalDateTime.class);
    JFormattedTextField ftf = getTextField();
    try {
      String maxString = formatter.valueToString(model.getStart());
      String minString = formatter.valueToString(model.getEnd());
      ftf.setColumns(Math.max(maxString.length(), minString.length()));
    } catch (ParseException ex) {
      // PENDING: hmuller
      ex.printStackTrace();
      UIManager.getLookAndFeel().provideErrorFeedback(ftf);
    }
    ftf.setHorizontalAlignment(SwingConstants.LEFT);
    ftf.setEditable(true);
    ftf.setFormatterFactory(new DefaultFormatterFactory(formatter));
  });
}
 
Example 10
Source Project: consulo   Source File: SingleIntegerFieldOptionsPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets integer number format to JFormattedTextField instance,
 * sets value of JFormattedTextField instance to object's field value,
 * synchronizes object's field value with the value of JFormattedTextField instance.
 *
 * @param textField  JFormattedTextField instance
 * @param owner      an object whose field is synchronized with {@code textField}
 * @param property   object's field name for synchronization
 */
public static void setupIntegerFieldTrackingValue(final JFormattedTextField textField,
                                                  final InspectionProfileEntry owner,
                                                  final String property) {
    NumberFormat formatter = NumberFormat.getIntegerInstance();
    formatter.setParseIntegerOnly(true);
    textField.setFormatterFactory(new DefaultFormatterFactory(new NumberFormatter(formatter)));
    textField.setValue(getPropertyValue(owner, property));
    final Document document = textField.getDocument();
    document.addDocumentListener(new DocumentAdapter() {
        @Override
        public void textChanged(DocumentEvent e) {
            try {
                textField.commitEdit();
                setPropertyValue(owner, property,
                        ((Number) textField.getValue()).intValue());
            } catch (ParseException e1) {
                // No luck this time
            }
        }
    });
}
 
Example 11
Source Project: atdl4j   Source File: SwingNullableSpinner.java    License: MIT License 6 votes vote down vote up
private NumberEditorNull(JSpinner spinner, DecimalFormat format) {
	super(spinner);
	if (!(spinner.getModel() instanceof SpinnerNumberModelNull)) {
		return;
	}
	
	SpinnerNumberModelNull model = (SpinnerNumberModelNull) spinner.getModel();
	NumberFormatter formatter = new NumberEditorFormatterNull(model, format);
	DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter);
	JFormattedTextField ftf = getTextField();
	ftf.setEditable(true);
	ftf.setFormatterFactory(factory);
	ftf.setHorizontalAlignment(JTextField.RIGHT);
	
	try {
		String maxString = formatter.valueToString(model.getMinimum());
		String minString = formatter.valueToString(model.getMaximum());
		ftf.setColumns(Math.max(maxString.length(), minString.length()));
	}
	catch (ParseException e) {
		// TBD should throw a chained error here
	}
}
 
Example 12
Source Project: darklaf   Source File: ColorValueFormatter.java    License: MIT License 5 votes vote down vote up
public static ColorValueFormatter init(final DarkColorModel model, final int index,
                                       final boolean hex, final JFormattedTextField text) {
    ColorValueFormatter formatter = new ColorValueFormatter(model, index, hex);
    formatter.setText(text);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
    return formatter;
}
 
Example 13
Source Project: jdk1.8-source-analysis   Source File: ValueFormatter.java    License: Apache License 2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 14
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 15
Source Project: ghidra   Source File: AbstractTextFilter.java    License: Apache License 2.0 5 votes vote down vote up
private JComponent createComponent(String filterName) {
	final JPanel panel = new JPanel(new BorderLayout());
	Border paddingBorder = BorderFactory.createEmptyBorder(1, 5, 1, 5);
	Border outsideBorder = BorderFactory.createBevelBorder(BevelBorder.LOWERED);
	panel.setBorder(BorderFactory.createCompoundBorder(outsideBorder, paddingBorder));

	DefaultFormatterFactory factory = new DefaultFormatterFactory(new DefaultFormatter());
	textField = new FilterFormattedTextField(factory, defaultValue);
	textField.setName(filterName + " Field"); // for debugging 	
	textField.setColumns(20);
	textField.setMinimumSize(textField.getPreferredSize());

	// we handle updates in real time, so ignore focus events, which trigger excess filtering
	textField.disableFocusEventProcessing();

	JLabel label = new GDLabel(filterName + ": ");
	panel.add(label, BorderLayout.WEST);
	panel.add(textField, BorderLayout.CENTER);

	StatusLabel nameFieldStatusLabel = new StatusLabel(textField, defaultValue);
	textField.addFilterStatusListener(nameFieldStatusLabel);
	textField.addFilterStatusListener(status -> fireStatusChanged(status));

	final JLayeredPane layeredPane = new JLayeredPane();
	layeredPane.add(panel, BASE_COMPONENT_LAYER);
	layeredPane.add(nameFieldStatusLabel, HOVER_COMPONENT_LAYER);

	layeredPane.setPreferredSize(panel.getPreferredSize());
	layeredPane.addComponentListener(new ComponentAdapter() {
		@Override
		public void componentResized(java.awt.event.ComponentEvent e) {
			Dimension preferredSize = layeredPane.getSize();
			panel.setBounds(0, 0, preferredSize.width, preferredSize.height);
			panel.validate();
		}
	});

	return layeredPane;
}
 
Example 16
Source Project: TencentKona-8   Source File: ValueFormatter.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 17
Source Project: jdk8u60   Source File: ValueFormatter.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 18
Source Project: JDKSourceCode1.8   Source File: ValueFormatter.java    License: MIT License 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 19
Source Project: openjdk-jdk8u   Source File: ValueFormatter.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 20
Source Project: marathonv5   Source File: IntegerEditor.java    License: Apache License 2.0 5 votes vote down vote up
public IntegerEditor(int min, int max) {
    super(new JFormattedTextField());
    ftf = (JFormattedTextField) getComponent();
    minimum = new Integer(min);
    maximum = new Integer(max);

    // Set up the editor for the integer cells.
    integerFormat = NumberFormat.getIntegerInstance();
    NumberFormatter intFormatter = new NumberFormatter(integerFormat);
    intFormatter.setFormat(integerFormat);
    intFormatter.setMinimum(minimum);
    intFormatter.setMaximum(maximum);

    ftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter));
    ftf.setValue(minimum);
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);

    // React when the user presses Enter while the editor is
    // active. (Tab is handled as specified by
    // JFormattedTextField's focusLostBehavior property.)
    ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    ftf.getActionMap().put("check", new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (!ftf.isEditValid()) { // The text is invalid.
                if (userSaysRevert()) { // reverted
                    ftf.postActionEvent(); // inform the editor
                }
            } else
                try { // The text is valid,
                    ftf.commitEdit(); // so use it.
                    ftf.postActionEvent(); // stop editing
                } catch (java.text.ParseException exc) {
                }
        }
    });
}
 
Example 21
Source Project: netbeans   Source File: AdvancedSecurityPanel.java    License: Apache License 2.0 5 votes vote down vote up
public AdvancedSecurityPanel(Binding binding, ConfigVersion cfgVersion) {
    this.binding = binding;
    this.cfgVersion = cfgVersion;
    
    freshnessff = new DefaultFormatterFactory();
    NumberFormat freshnessFormat = NumberFormat.getIntegerInstance();
    freshnessFormat.setGroupingUsed(false);
    NumberFormatter freshnessFormatter = new NumberFormatter(freshnessFormat);
    freshnessFormat.setMaximumIntegerDigits(8);
    freshnessFormatter.setCommitsOnValidEdit(true);
    freshnessFormatter.setMinimum(0);
    freshnessFormatter.setMaximum(99999999);
    freshnessff.setDefaultFormatter(freshnessFormatter);
            
    skewff = new DefaultFormatterFactory();
    NumberFormat skewFormat = NumberFormat.getIntegerInstance();
    skewFormat.setGroupingUsed(false);
    NumberFormatter skewFormatter = new NumberFormatter(skewFormat);
    skewFormat.setMaximumIntegerDigits(8);
    skewFormatter.setCommitsOnValidEdit(true);
    skewFormatter.setMinimum(0);
    skewFormatter.setMaximum(99999999);
    skewff.setDefaultFormatter(skewFormatter);

    initComponents();
    
    sync();
}
 
Example 22
Source Project: netbeans   Source File: AdvancedRMPanel.java    License: Apache License 2.0 5 votes vote down vote up
public AdvancedRMPanel(Binding binding, ConfigVersion cfgVersion) {
    super();
    this.binding = binding;
    this.cfgVersion = cfgVersion;

    milisecondsff = new DefaultFormatterFactory();
    NumberFormat millisecondsFormat = NumberFormat.getIntegerInstance();        
    millisecondsFormat.setGroupingUsed(false);
    NumberFormatter millisecondsFormatter = new NumberFormatter(millisecondsFormat);
    millisecondsFormat.setMaximumIntegerDigits(8);
    millisecondsFormatter.setCommitsOnValidEdit(true);
    millisecondsFormatter.setMinimum(0);
    millisecondsFormatter.setMaximum(99999999);
    milisecondsff.setDefaultFormatter(millisecondsFormatter);

    maxBufff = new DefaultFormatterFactory();
    NumberFormat maxBufFormat = NumberFormat.getIntegerInstance();
    maxBufFormat.setGroupingUsed(false);
    NumberFormatter maxBufFormatter = new NumberFormatter(maxBufFormat);
    maxBufFormat.setMaximumIntegerDigits(8);
    maxBufFormatter.setCommitsOnValidEdit(true);
    maxBufFormatter.setMinimum(0);
    maxBufFormatter.setMaximum(99999999);
    maxBufff.setDefaultFormatter(maxBufFormatter);

    initComponents();

    inSync = true;
    for (RMDeliveryAssurance assurance : RMDeliveryAssurance.values()) {
        deliveryAssuranceCombo.addItem(assurance);
    }
    inSync = false;
    
    sync();
    refresh();
}
 
Example 23
Source Project: netbeans   Source File: STSConfigServicePanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form STSConfigServicePanel
 */
public STSConfigServicePanel( Project p, Binding binding, ConfigVersion cfgVersion) {
    this.project = p;
    this.binding = binding;
    this.cfgVersion = cfgVersion;

    lifeTimeDff = new DefaultFormatterFactory();
    NumberFormat lifetimeFormat = NumberFormat.getIntegerInstance();
    lifetimeFormat.setGroupingUsed(false);
    lifetimeFormat.setParseIntegerOnly(true);
    lifetimeFormat.setMaximumFractionDigits(0);
    NumberFormatter lifetimeFormatter = new NumberFormatter(lifetimeFormat);
    lifetimeFormatter.setCommitsOnValidEdit(true);
    lifetimeFormatter.setMinimum(0);
    lifeTimeDff.setDefaultFormatter(lifetimeFormatter);

    initComponents();

    inSync = true;
    ServiceProvidersTablePanel.ServiceProvidersTableModel tablemodel = new ServiceProvidersTablePanel.ServiceProvidersTableModel();
    this.remove(serviceProvidersPanel);
    
    STSConfiguration stsConfig = ProprietarySecurityPolicyModelHelper.getSTSConfiguration(binding);
    if (stsConfig == null) {
        stsConfig = ProprietarySecurityPolicyModelHelper.createSTSConfiguration(binding);
    }
    serviceProvidersPanel = new ServiceProvidersTablePanel(tablemodel, stsConfig, cfgVersion);
    ((ServiceProvidersTablePanel)serviceProvidersPanel).populateModel();
    inSync = false;

    sync();
    
}
 
Example 24
Source Project: Bytecoder   Source File: ValueFormatter.java    License: Apache License 2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 25
Source Project: openjdk-jdk9   Source File: ValueFormatter.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 26
Source Project: jdk8u-jdk   Source File: ValueFormatter.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 27
Source Project: gcs   Source File: PrintPanel.java    License: Mozilla Public License 2.0 5 votes vote down vote up
private void createCopiesField(PrintRequestAttributeSet set) {
    PrintService service = getService();
    if (service.isAttributeCategorySupported(Copies.class)) {
        mCopies = new EditorField(new DefaultFormatterFactory(new IntegerFormatter(1, 999, false)), null, SwingConstants.RIGHT, Integer.valueOf(PrintUtilities.getCopies(service, set)), Integer.valueOf(999), null);
        UIUtilities.setToPreferredSizeOnly(mCopies);
        LinkedLabel label = new LinkedLabel(I18n.Text("Copies"), mCopies);
        add(label, new PrecisionLayoutData().setEndHorizontalAlignment());
        add(mCopies);
    } else {
        mCopies = null;
    }
}
 
Example 28
Source Project: gcs   Source File: EditorPanel.java    License: 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 29
Source Project: gcs   Source File: EditorPanel.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/**
 * @param compare   The current compare object.
 * @param min       The minimum value to allow.
 * @param max       The maximum value to allow.
 * @param forceSign Whether to force the sign to be visible.
 * @return The {@link EditorField} that allows an integer comparison to be changed.
 */
protected EditorField addNumericCompareField(IntegerCriteria compare, int min, int max, boolean forceSign) {
    EditorField field = new EditorField(new DefaultFormatterFactory(new IntegerFormatter(min, max, forceSign)), this, SwingConstants.LEFT, Integer.valueOf(compare.getQualifier()), Integer.valueOf(max), null);
    field.putClientProperty(IntegerCriteria.class, compare);
    UIUtilities.setToPreferredSizeOnly(field);
    add(field);
    return field;
}
 
Example 30
Source Project: gcs   Source File: EditorPanel.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/**
 * @param compare   The current compare object.
 * @param min       The minimum value to allow.
 * @param max       The maximum value to allow.
 * @param forceSign Whether to force the sign to be visible.
 * @return The {@link EditorField} that allows a double comparison to be changed.
 */
protected EditorField addNumericCompareField(DoubleCriteria compare, double min, double max, boolean forceSign) {
    EditorField field = new EditorField(new DefaultFormatterFactory(new DoubleFormatter(min, max, forceSign)), this, SwingConstants.LEFT, Double.valueOf(compare.getQualifier()), Double.valueOf(max), null);
    field.putClientProperty(DoubleCriteria.class, compare);
    UIUtilities.setToPreferredSizeOnly(field);
    add(field);
    return field;
}