Package javax.swing.text

Examples of javax.swing.text.InternationalFormatter


  implements Testlet
{
 
  public void test(TestHarness harness)
  {
    InternationalFormatter formatter = new InternationalFormatter();
    harness.check (!formatter.getCommitsOnValidEdit());
    harness.check (formatter.getAllowsInvalid());
    harness.check (!formatter.getOverwriteMode());
  }
View Full Code Here


        if (format instanceof DateFormat) {
            return new DateFormatter((DateFormat)format);
        } else if (format instanceof NumberFormat) {
            return new NumberFormatter((NumberFormat)format);
        } else {
            return new InternationalFormatter(format);
        }
    }
View Full Code Here

        final JFormattedTextField ftf = new JFormattedTextField(value);
        assertEquals("", ftf.getText());
    }

    public void testJFormattedTextFieldAbstractFormatter() {
        InternationalFormatter formatter = new InternationalFormatter();
        JFormattedTextField tf1 = new JFormattedTextField(formatter);
        assertNull(tf1.getValue());
        assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf1.getFocusLostBehavior());
        assertEquals(formatter, tf1.getFormatter());
        assertTrue(tf1.getFormatterFactory() instanceof DefaultFormatterFactory);
View Full Code Here

        assertNull(factory.getNullFormatter());
    }

    public void testJFormattedTextFieldFormat() {
        Format format = new SimpleDateFormat();
        InternationalFormatter formatter;
        DefaultFormatterFactory factory;
        JFormattedTextField tf1 = new JFormattedTextField(format);
        assertNull(tf1.getValue());
        assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf1.getFocusLostBehavior());
        assertTrue(tf1.getFormatter() instanceof DateFormatter);
        formatter = (InternationalFormatter) tf1.getFormatter();
        assertEquals(format, formatter.getFormat());
        assertTrue(tf1.getFormatterFactory() instanceof DefaultFormatterFactory);
        factory = (DefaultFormatterFactory) tf1.getFormatterFactory();
        assertEquals(formatter, factory.getDefaultFormatter());
        format = new MessageFormat("");
        tf1 = new JFormattedTextField(format);
        assertTrue(tf1.getFormatter() instanceof InternationalFormatter);
        formatter = (InternationalFormatter) tf1.getFormatter();
        assertEquals(format, formatter.getFormat());
        factory = (DefaultFormatterFactory) tf1.getFormatterFactory();
        assertEquals(formatter, factory.getDefaultFormatter());
        format = new DecimalFormat();
        tf1 = new JFormattedTextField(format);
        assertTrue(tf1.getFormatter() instanceof NumberFormatter);
        formatter = (InternationalFormatter) tf1.getFormatter();
        assertEquals(format, formatter.getFormat());
        factory = (DefaultFormatterFactory) tf1.getFormatterFactory();
        assertEquals(formatter, factory.getDefaultFormatter());
    }
View Full Code Here

        if (format instanceof DateFormat) {
            return new DateFormatter((DateFormat) format);
        } else if (format instanceof NumberFormat) {
            return new NumberFormatter((NumberFormat) format);
        } else {
            return new InternationalFormatter(format);
        }
    }
View Full Code Here

      return griddedPanel;
  }
 
    @SuppressWarnings("serial")
  private JTextField createPaddingTextField(AxisType axisType, AxisBounds bound) {
      final JFormattedTextField tField = new JFormattedTextField(new InternationalFormatter(
          NumberFormat.getIntegerInstance()) {
            protected DocumentFilter getDocumentFilter() {
              return filter;
            }
            private DocumentFilter filter = new PaddingFilter();
View Full Code Here

        final JFormattedTextField ftf = new JFormattedTextField(value);
        assertEquals("", ftf.getText());
    }

    public void testJFormattedTextFieldAbstractFormatter() {
        InternationalFormatter formatter = new InternationalFormatter();
        JFormattedTextField tf1 = new JFormattedTextField(formatter);
        assertNull(tf1.getValue());
        assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf1.getFocusLostBehavior());
        assertEquals(formatter, tf1.getFormatter());
        assertTrue(tf1.getFormatterFactory() instanceof DefaultFormatterFactory);
View Full Code Here

        assertNull(factory.getNullFormatter());
    }

    public void testJFormattedTextFieldFormat() {
        Format format = new SimpleDateFormat();
        InternationalFormatter formatter;
        DefaultFormatterFactory factory;
        JFormattedTextField tf1 = new JFormattedTextField(format);
        assertNull(tf1.getValue());
        assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf1.getFocusLostBehavior());
        assertTrue(tf1.getFormatter() instanceof DateFormatter);
        formatter = (InternationalFormatter) tf1.getFormatter();
        assertEquals(format, formatter.getFormat());
        assertTrue(tf1.getFormatterFactory() instanceof DefaultFormatterFactory);
        factory = (DefaultFormatterFactory) tf1.getFormatterFactory();
        assertEquals(formatter, factory.getDefaultFormatter());
        format = new MessageFormat("");
        tf1 = new JFormattedTextField(format);
        assertTrue(tf1.getFormatter() instanceof InternationalFormatter);
        formatter = (InternationalFormatter) tf1.getFormatter();
        assertEquals(format, formatter.getFormat());
        factory = (DefaultFormatterFactory) tf1.getFormatterFactory();
        assertEquals(formatter, factory.getDefaultFormatter());
        format = new DecimalFormat();
        tf1 = new JFormattedTextField(format);
        assertTrue(tf1.getFormatter() instanceof NumberFormatter);
        formatter = (InternationalFormatter) tf1.getFormatter();
        assertEquals(format, formatter.getFormat());
        factory = (DefaultFormatterFactory) tf1.getFormatterFactory();
        assertEquals(formatter, factory.getDefaultFormatter());
    }
View Full Code Here

            public AbstractFormatter getFormatter(JFormattedTextField field) {
                NumberFormat format = DecimalFormat.getInstance();
                format.setMinimumFractionDigits(2);
                format.setMaximumFractionDigits(2);
                format.setRoundingMode(RoundingMode.HALF_UP);
                InternationalFormatter formatter = new InternationalFormatter(format);
                formatter.setAllowsInvalid(false);
                formatter.setMinimum(0.0);
                formatter.setMaximum(10000000.00);
                return formatter;
            }
        });
       
    }
View Full Code Here

      if (child instanceof DateFormat)
        factory = new DefaultFormatterFactory(new DateFormatter((DateFormat)child));
      else if (child instanceof NumberFormat)
        factory = new DefaultFormatterFactory(new NumberFormatter((NumberFormat)child));
      else
        factory = new DefaultFormatterFactory(new InternationalFormatter((Format)child));
      ((JFormattedTextField)parent).setFormatterFactory (factory);
    }
    else if (child instanceof JFormattedTextField.AbstractFormatter)
    {
      ((JFormattedTextField)parent).setFormatterFactory (new DefaultFormatterFactory ((JFormattedTextField.AbstractFormatter)child));
View Full Code Here

TOP

Related Classes of javax.swing.text.InternationalFormatter

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.