Package javax.swing.JFormattedTextField

Examples of javax.swing.JFormattedTextField.AbstractFormatter


     */
    public DateFormat[] getFormats() {
        // Dig this out from the factory, if possible, otherwise return null.
        AbstractFormatterFactory factory = _dateField.getFormatterFactory();
        if (factory != null) {
            AbstractFormatter formatter = factory.getFormatter(_dateField);
            if (formatter instanceof DatePickerFormatter) {
                return ((DatePickerFormatter) formatter).getFormats();
            }
        }
        return EMPTY_DATE_FORMATS;
View Full Code Here


//                null);
//        ((DataField)this._component).setFormatterFactory(dff);
//        ((DataField)this._component).setOriginalFormatText(this.value.toString());

      DataField df = (DataField)this._component;
      AbstractFormatter af = df.getFormatter();
      Class<?> valueClass = null;
      if (af instanceof DefaultFormatter) {
        valueClass = ((DefaultFormatter)af).getValueClass();
      }
    NumericFormatter formatter = new NumericFormatter((DataField)this._component, this.value.toString(), valueClass);
View Full Code Here

//                null);
//        ((DataField)this._component).setFormatterFactory(dff);
//        ((DataField)this._component).setOriginalFormatText(this.value.toString());

      DataField df = (DataField)this._component;
      AbstractFormatter af = df.getFormatter();
      Class<?> valueClass = null;
      if (af instanceof DefaultFormatter) {
        valueClass = ((DefaultFormatter)af).getValueClass();
      }
    NumericFormatter formatter = new NumericFormatter((DataField)this._component, this.value.toString(), valueClass);
View Full Code Here

    public boolean verify(JComponent input) {

        if (input instanceof DataField && !this.getAllowIncompleteFields()){
            DataField df = (DataField)input;

            AbstractFormatter formatter = df.getFormatter();

            if (formatter != null) {
                //  attempt to apply the mask to the text ....
                String text = df.getText();
                try {
                    formatter.stringToValue(text);
                    df.thisFieldIsInError = false;
                    return true;
                }
                catch (ParseException pe) {
                    //  the text did not match the mask .... lets see if the text is really empty
                        if (df.firstKey) {
                            df.thisFieldIsInError = false;
                            return true;
                        }
                        else if (this.allowsEmptyMasks) {
                        try {
                            String mask = formatter.valueToString(null);

                            if (mask.equals(text)) {
                                //  the mask is empty ... this is OK ... make sure that the datafield is really empty
                                df.clearValue();
                                df.thisFieldIsInError = false;
View Full Code Here

//                null);
//        ((DataField)this._component).setFormatterFactory(dff);
//        ((DataField)this._component).setOriginalFormatText(this.value.toString());

      DataField df = (DataField)this._component;
      AbstractFormatter af = df.getFormatter();
      Class<?> valueClass = null;
      if (af instanceof DefaultFormatter) {
        valueClass = ((DefaultFormatter)af).getValueClass();
      }
    NumericFormatter formatter = new NumericFormatter((DataField)this._component, this.value.toString(), valueClass);
View Full Code Here

    public boolean verify(JComponent input) {

        if (input instanceof DataField && !this.getAllowIncompleteFields()){
            DataField df = (DataField)input;

            AbstractFormatter formatter = df.getFormatter();

            if (formatter != null) {
                //  attempt to apply the mask to the text ....
                String text = df.getText();
                try {
                    formatter.stringToValue(text);
                    df.thisFieldIsInError = false;
                    return true;
                }
                catch (ParseException pe) {
                    //  the text did not match the mask .... lets see if the text is really empty
                        if (df.firstKey) {
                            df.thisFieldIsInError = false;
                            return true;
                        }
                        else if (this.allowsEmptyMasks) {
                        try {
                            String mask = formatter.valueToString(null);

                            if (mask.equals(text)) {
                                //  the mask is empty ... this is OK ... make sure that the datafield is really empty
                                df.clearValue();
                                df.thisFieldIsInError = false;
View Full Code Here

    public boolean verify(JComponent input) {

        if (input instanceof DataField && !this.getAllowIncompleteFields()){
            DataField df = (DataField)input;

            AbstractFormatter formatter = df.getFormatter();

            if (formatter != null) {
                //  attempt to apply the mask to the text ....
                String text = df.getText();
                try {
                    formatter.stringToValue(text);
                    df.thisFieldIsInError = false;
                    return true;
                }
                catch (ParseException pe) {
                    //  the text did not match the mask .... lets see if the text is really empty
                        if (df.firstKey) {
                            df.thisFieldIsInError = false;
                            return true;
                        }
                        else if (this.allowsEmptyMasks) {
                        try {
                            String mask = formatter.valueToString(null);

                            if (mask.equals(text)) {
                                //  the mask is empty ... this is OK ... make sure that the datafield is really empty
                                df.clearValue();
                                df.thisFieldIsInError = false;
View Full Code Here

        assertEquals(1, valueListener.eventCount());
    }
   
    private static final class OnlyAlowLowerCaseFormatterFactory extends AbstractFormatterFactory {
        public AbstractFormatter getFormatter(JFormattedTextField tf) {
            return new AbstractFormatter() {

                public Object stringToValue(String text) throws ParseException {
                    if (text != null && !text.equals(text.toLowerCase())) {
                        throw new ParseException(text, 0);
                    }
View Full Code Here

        JComponent comp = new JButton();
        Object[] values = { "arrline1", "arrline2", "text", new Integer(33), comp };
        spinner.setModel(new SpinnerListModel(values));
        ListEditor listEditor = new ListEditor(spinner);
        spinner.setEditor(listEditor);
        AbstractFormatter formatter = ((ListEditor) spinner.getEditor()).getTextField()
                .getFormatter();
        assertEquals(formatter.valueToString(null), "");
        assertEquals(formatter.valueToString(new Integer(33)), "33");
        assertEquals(formatter.stringToValue("text"), "text");
    }
View Full Code Here

    private DateFormat[] getCustomFormats(JFormattedTextField editor) {
        DateFormat[] formats = null;
        if (editor != null) {
            AbstractFormatterFactory factory = editor.getFormatterFactory();
            if (factory != null) {
                AbstractFormatter formatter = factory.getFormatter(editor);
                // fix for #1144: classCastException for custom formatters
                // PENDING JW: revisit for #1138
                if ((formatter instanceof DatePickerFormatter) && !(formatter instanceof UIResource)) {
//                if (!(formatter instanceof DatePickerFormatterUIResource))  {
                    formats = ((DatePickerFormatter) formatter).getFormats();
View Full Code Here

TOP

Related Classes of javax.swing.JFormattedTextField.AbstractFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.