Java 8 DefaultFormatterFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DefaultFormatterFactory class.

This code example shows how to use the following methods:
     * Convenience method for creating a formatter factory with a 
     * {@code ScalableNumberFormatter} and a Java-style DecimalFormat. 
     */ 
    public static AbstractFormatterFactory createFormatterFactory(double min, double max, double multiplier, boolean allowsNullValue, @Nullable String unit) {
        JavaNumberFormatter formatter = new JavaNumberFormatter(min, max, multiplier, allowsNullValue, unit);
        return new DefaultFormatterFactory(formatter);
    } 
} 
3
CodeRank
This code example shows how to use the following methods:
			if (numberHolder.getValue() != null)
			{ 
				textField.setValue(numberHolder.getValue());
			} 
 
			textField.setFormatterFactory(new DefaultFormatterFactory(newFormatter));
		} 
		finally 
		{ 
			installingFormatter = false;
		} 
	} 
 
	private SpinnerModel spinnerModel() 
	{ 
		return (SpinnerModel) spinner.getModel();
	} 
 
	/** 
	 * The subject has changed and if it's was nullified, then show the default 
3
CodeRank
This code example shows how to use the following methods:
        if (!(spinner.getModel() instanceof SpecialValueSpinnerModel))
            throw new IllegalArgumentException("model not a SpecialValueSpinnerModel");
 
        SpecialValueSpinnerModel model = (SpecialValueSpinnerModel) spinner.getModel();
        NumberFormatter formatter = new NumberEditorFormatter(model, format);
        DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter);
        JFormattedTextField ftf = getTextField();
        ftf.setEditable(true);
        ftf.setFormatterFactory(factory);
        ftf.setHorizontalAlignment(SwingConstants.RIGHT);
 
        /* 
         * TBD - initializing the column width of the text field 
         * is imprecise and doing it here is tricky because 
         * the developer may configure the formatter later. 
         */ 
        try 
        { 
            String maxString = formatter.valueToString(model.getMinimum());
            String minString = formatter.valueToString(model.getMaximum());
3
CodeRank
This code example shows how to use the following methods:
        } 
 
        //textField.setFormatterFactory(new DefaultFormatterFactory(dateFormatter)); 
        if (inputMask != null) {
            inputMask.setAllowsInvalid(true);
            textField.setFormatterFactory(new DefaultFormatterFactory(inputMask));
        } 
 
        // set initial value to lowest possible date. 
        //textField.setValue(nv.getVal1()); 
        textField.setFocusLostBehavior(JFormattedTextField.PERSIST);
 
        textField.getInputMap()
                .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "validate");
        textField.getActionMap().put("validate",
                new AbstractAction() {
                    public void actionPerformed(ActionEvent e) {
                        if (!textField.isEditValid()) { //The text is invalid.
                            textField.postActionEvent();
                        } else { 
4
CodeRank
This code example shows how to use the following methods:
            } 
 
            SpinnerMathNumberModel model = (SpinnerMathNumberModel)spinner.getModel();
            NumberFormatter formatter = new MathNumberEditorFormatter(model,
                                                                  format);
            DefaultFormatterFactory factory = new DefaultFormatterFactory(
                                                  formatter);
            JFormattedTextField ftf = getTextField();
            ftf.setEditable(true);
            ftf.setFormatterFactory(factory);
            ftf.setHorizontalAlignment(JTextField.RIGHT);
 
            /* TBD - initializing the column width of the text field 
             * is imprecise and doing it here is tricky because 
             * the developer may configure the formatter later. 
             */ 
            try { 
                String maxString = formatter.valueToString(model.getMinimum());
                String minString = formatter.valueToString(model.getMaximum());
                ftf.setColumns(Math.max(maxString.length(),
4
CodeRank
This code example shows how to use the following methods:
 
    public JTextField getNameTextField() {
        if (nameTextField == null) {
            DefaultFormatter formatter = new DefaultFormatter();
            formatter.setOverwriteMode(false);
            nameTextField = new JFormattedTextField(new DefaultFormatterFactory(formatter));
            nameTextField.addPropertyChangeListener("value", this);
        } 
        return nameTextField;
    } 
 
    public JLabel getNameLabel() {
        if (nameLabel == null) {
            nameLabel = new JLabel("Diagram Name: ");
        } 
        return nameLabel;
    } 
 
    public void configureDiagram(Diagram diagram) {
        this.diagram = diagram;
3
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
        add(relation, BorderLayout.WEST);
        add(integer, BorderLayout.CENTER);
        NumberFormat format = NumberFormat.getIntegerInstance();
        format.setGroupingUsed(false);
        NumberFormatter formatter = new NumberFormatter(format);
        DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter);
        integer.setFormatterFactory(factory);
        integer.setHorizontalAlignment(JFormattedTextField.RIGHT);
        setParameter(new IntegerRelation()); 
    } 
 
    public void setParameter(@Nullable Object parameter) { 
        IntegerRelation rel;
        if (parameter != null) { 
            rel = (IntegerRelation) parameter;
        } else { 
            rel = new IntegerRelation();
        } 
        integer.setValue(rel.getInteger());
        relation.setSelectedItem(relationMap.get(rel.getRelation().getType()));
4
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
See Code Examples for Java 8 DefaultFormatterFactory Methods: