Package javax.swing.text

Examples of javax.swing.text.DateFormatter


   @Test
   public void shouldBindFormattedValueToModel() throws Exception
   {
      // given
      JFormattedTextField textField = new JFormattedTextField(new DateFormatter());
      ModelForTests model = new ModelForTests();
      bind().valueOf(textField).to(model, ModelForTests.DATE);
      Calendar calendar = Calendar.getInstance();
      calendar.set(2010, 4, 10);
      // when
View Full Code Here


   @Test
   public void shouldBindModelToFormattedValue() throws Exception
   {
      // given
      JFormattedTextField textField = new JFormattedTextField(new DateFormatter());
      ModelForTests model = new ModelForTests();
      bind().valueOf(model, ModelForTests.DATE).toValueOf(textField);
      Calendar calendar = Calendar.getInstance();
      calendar.set(2010, Calendar.APRIL, 10);
      // when
View Full Code Here

      return false;
    if (child instanceof Format)
    {
      DefaultFormatterFactory factory;
      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);
View Full Code Here

  /**
   * @return the txtDate
   */
  public JFormattedTextField getTxtDate() {
    if (txtDate == null) {
      DateFormatter formatter = new DateFormatter(
        getDateFormat());
      DefaultFormatterFactory dffactory = new DefaultFormatterFactory(
        formatter);
      txtDate = new JFormattedTextField(dffactory);
      txtDate.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);
View Full Code Here

  /**
   * @param dateFormat the dateFormat to set
   */
  public void setDateFormat(DateFormat dateFormat) {
    this.dateFormat = dateFormat;
    DateFormatter formatter = new DateFormatter(
      this.dateFormat);
    DefaultFormatterFactory dffactory = new DefaultFormatterFactory(
      formatter);
    txtDate.setFormatterFactory(dffactory);
  }
View Full Code Here

    /**
     * @return the txtDate
     */
    protected JFormattedTextField getTxtDate() {
        if (txtDate == null) {
            DateFormatter formatter = new DateFormatter(
                    getDateFormat());
            DefaultFormatterFactory dffactory = new DefaultFormatterFactory(
                    formatter);
            txtDate = new CalendarFormattedText(dffactory);
            txtDate.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);
View Full Code Here

TOP

Related Classes of javax.swing.text.DateFormatter

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.