Java 类javax.swing.text.DateFormatter 实例源码

项目:PhET    文件:DateEditor.java   
public DateEditor() {
    super( new JFormattedTextField() );
    textField = (JFormattedTextField) getComponent();

    textField.setFormatterFactory( new DefaultFormatterFactory( new DateFormatter( Entry.LOAD_FORMAT ) ) );
    textField.setFocusLostBehavior( JFormattedTextField.PERSIST );

    textField.getInputMap().put( KeyStroke.getKeyStroke( KeyEvent.VK_ENTER, 0 ), "check" );
    textField.getActionMap().put( "check", new AbstractAction() {
        public void actionPerformed( ActionEvent e ) {
            if ( !textField.isEditValid() ) { //The text is invalid.
                if ( userSaysRevert() ) { //reverted
                    textField.postActionEvent(); //inform the editor
                }
            }
            else {
                try {              //The text is valid,
                    textField.commitEdit();     //so use it.
                    textField.postActionEvent(); //stop editing
                }
                catch ( java.text.ParseException exc ) {
                }
            }
        }
    } );
}
项目:High-Frequency-Data-Order-Book-Analyser    文件:SimulationParameters.java   
/**
 * Creates new form FileSelection
 */
public SimulationParameters() {
    initComponents();
    this.setResizable(false);
    this.setTitle("File Selection");
    fileReader = new FileRead();
    initialiseDateComboBox(fileReader);

    JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(SpinnerTime, "HH:mm:ss");
    DateFormatter formatter = (DateFormatter) timeEditor.getTextField().getFormatter();
    formatter.setAllowsInvalid(false); // Make sure no invalid input is allowed
    SpinnerTime.setEditor(timeEditor);
    String StartTime = "08:30:00";
    Date time;
    try {
        time = new SimpleDateFormat("HH:mm:ss").parse(StartTime);
        SpinnerTime.setValue(time); // will only show the current time
    } catch (ParseException ex) {
        Logger.getLogger(SimulationParameters.class.getName()).log(Level.SEVERE, null, ex);
    }
}
项目:jspresso-ce    文件:JDateField.java   
private void initDefaultBehaviour(Locale locale) {
  setRenderer(new FixedDayRenderer());
  setHeaderRenderer(new TranslatedHeaderRenderer(locale));
  new FormatSymbols((DateFormatter) getFormattedTextField().getFormatter(),
      locale);
  getFormattedTextField().setBorder(
      BorderFactory.createEmptyBorder(1, 5, 1, 5));
  SwingUtil.enableSelectionOnFocusGained(getFormattedTextField());
  addFocusListener(new FocusAdapter() {

    @Override
    public void focusGained(FocusEvent e) {
      if (!e.isTemporary()) {
        JTextField tf = ((DateField) e.getSource()).getFormattedTextField();
        tf.requestFocusInWindow();
      }
    }
  });
  setValue(null);
}
项目:poc-opennms-spreadsheet-category-manager    文件:Starter.java   
@Deprecated
//not used yet
private File setupWorkspace() {
    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    DateFormatter dateFormatter = new DateFormatter(dateFormat);
    String dateString = "not_set_yet";
    File workspace = null;
    try {
        dateString = dateFormatter.valueToString(new Date());
        workspace = new File(WORKSPACE_NAME + File.separator + dateString);
        workspace.mkdirs();
    } catch (ParseException ex) {
        logger.error("Date String parsing went wrong", ex);
    }
    if (workspace != null && !(workspace.exists() && workspace.canRead() && workspace.canWrite())) {
        logger.error("Problem with Workspace folder '{}'", WORKSPACE_NAME + File.separator + dateString);
        System.exit(1);
    }
    return workspace;
}
项目:cn1    文件:JFormattedTextFieldTest.java   
public void testCreateFormattersFactory() {
    DefaultFormatterFactory factory;
    tf.setValue(new Integer(34));
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    assertTrue(factory.getDefaultFormatter() instanceof NumberFormatter);
    //TODO: check if factory.getDefaultFormatter() should be same to factory.getDisplayFormatter()
    // or factory.getEditFormatter().
    assertNull(factory.getNullFormatter());
    tf.setFormatterFactory(null);
    tf.setValue(new Date());
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    assertTrue(factory.getDefaultFormatter() instanceof DateFormatter);
    assertNull(factory.getDisplayFormatter());
    assertNull(factory.getEditFormatter());
    assertNull(factory.getNullFormatter());
    tf.setFormatterFactory(null);
    tf.setValue("sdffsdf");
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    checkDefaultFormatter(factory);
    tf.setFormatterFactory(null);
    tf.setValue(Color.RED);
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    checkDefaultFormatter(factory);
}
项目:cn1    文件:JSpinnerTest.java   
public void testDateEditor_DateEditor() {
    spinner.setModel(new SpinnerDateModel());
    DateEditor dateEditor = (DateEditor) spinner.getEditor();
    spinner.setEditor(dateEditor);
    assertTrue(dateEditor.getTextField().isEditable());
    assertTrue(dateEditor.getTextField().getFormatter() instanceof DateFormatter);
    assertNull(((DateFormatter) dateEditor.getTextField().getFormatter()).getMinimum());
    assertNull(((DateFormatter) dateEditor.getTextField().getFormatter()).getMaximum());
    assertTrue(dateEditor.getFormat().equals(new SimpleDateFormat()));
    spinner.setModel(abstractModel);
    testExceptionalCase(new IllegalArgumentCase() {
        @Override
        public void exceptionalAction() throws Exception {
            new JSpinner.DateEditor(spinner);
        }
    });
}
项目:cn1    文件:JSpinnerTest.java   
public void testDateEditor_formatter() {
    spinner.setModel(new SpinnerDateModel());
    DateEditor dateEditor = new DateEditor(spinner);
    spinner.setEditor(dateEditor);
    final Date date1 = new Date(777);
    DateFormatter dateFormatter = ((DateFormatter) dateEditor.getTextField().getFormatter());
    dateFormatter.setMaximum(date1);
    assertSame(dateFormatter.getMaximum(), date1);
    assertSame(dateEditor.getModel().getEnd(), date1);
    final Date date2 = new Date(555);
    dateEditor.getModel().setEnd(date2);
    assertSame(dateFormatter.getMaximum(), date2);
    assertSame(dateEditor.getModel().getEnd(), date2);
    SpinnerDateModel old = (SpinnerDateModel) spinner.getModel();
    spinner.setModel(abstractModel);
    final Date date3 = new Date(555);
    old.setEnd(date3);
    assertEquals(((DateFormatter) ((DateEditor) spinner.getEditor()).getTextField()
            .getFormatter()).getMaximum(), date3);
}
项目:freeVM    文件:JFormattedTextFieldTest.java   
public void testCreateFormattersFactory() {
    DefaultFormatterFactory factory;
    tf.setValue(new Integer(34));
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    assertTrue(factory.getDefaultFormatter() instanceof NumberFormatter);
    //TODO: check if factory.getDefaultFormatter() should be same to factory.getDisplayFormatter()
    // or factory.getEditFormatter().
    assertNull(factory.getNullFormatter());
    tf.setFormatterFactory(null);
    tf.setValue(new Date());
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    assertTrue(factory.getDefaultFormatter() instanceof DateFormatter);
    assertNull(factory.getDisplayFormatter());
    assertNull(factory.getEditFormatter());
    assertNull(factory.getNullFormatter());
    tf.setFormatterFactory(null);
    tf.setValue("sdffsdf");
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    checkDefaultFormatter(factory);
    tf.setFormatterFactory(null);
    tf.setValue(Color.RED);
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    checkDefaultFormatter(factory);
}
项目:freeVM    文件:JSpinnerTest.java   
public void testDateEditor_DateEditor() {
    spinner.setModel(new SpinnerDateModel());
    DateEditor dateEditor = (DateEditor) spinner.getEditor();
    spinner.setEditor(dateEditor);
    assertTrue(dateEditor.getTextField().isEditable());
    assertTrue(dateEditor.getTextField().getFormatter() instanceof DateFormatter);
    assertNull(((DateFormatter) dateEditor.getTextField().getFormatter()).getMinimum());
    assertNull(((DateFormatter) dateEditor.getTextField().getFormatter()).getMaximum());
    assertTrue(dateEditor.getFormat().equals(new SimpleDateFormat()));
    spinner.setModel(abstractModel);
    testExceptionalCase(new IllegalArgumentCase() {
        @Override
        public void exceptionalAction() throws Exception {
            new JSpinner.DateEditor(spinner);
        }
    });
}
项目:freeVM    文件:JFormattedTextFieldTest.java   
public void testCreateFormattersFactory() {
    DefaultFormatterFactory factory;
    tf.setValue(new Integer(34));
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    assertTrue(factory.getDefaultFormatter() instanceof NumberFormatter);
    //TODO: check if factory.getDefaultFormatter() should be same to factory.getDisplayFormatter()
    // or factory.getEditFormatter().
    assertNull(factory.getNullFormatter());
    tf.setFormatterFactory(null);
    tf.setValue(new Date());
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    assertTrue(factory.getDefaultFormatter() instanceof DateFormatter);
    assertNull(factory.getDisplayFormatter());
    assertNull(factory.getEditFormatter());
    assertNull(factory.getNullFormatter());
    tf.setFormatterFactory(null);
    tf.setValue("sdffsdf");
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    checkDefaultFormatter(factory);
    tf.setFormatterFactory(null);
    tf.setValue(Color.RED);
    factory = getFactoryIfDefault(tf.getFormatterFactory());
    checkDefaultFormatter(factory);
}
项目:freeVM    文件:JSpinnerTest.java   
public void testDateEditor_DateEditor() {
    spinner.setModel(new SpinnerDateModel());
    DateEditor dateEditor = (DateEditor) spinner.getEditor();
    spinner.setEditor(dateEditor);
    assertTrue(dateEditor.getTextField().isEditable());
    assertTrue(dateEditor.getTextField().getFormatter() instanceof DateFormatter);
    assertNull(((DateFormatter) dateEditor.getTextField().getFormatter()).getMinimum());
    assertNull(((DateFormatter) dateEditor.getTextField().getFormatter()).getMaximum());
    assertTrue(dateEditor.getFormat().equals(new SimpleDateFormat()));
    spinner.setModel(abstractModel);
    testExceptionalCase(new IllegalArgumentCase() {
        @Override
        public void exceptionalAction() throws Exception {
            new JSpinner.DateEditor(spinner);
        }
    });
}
项目:freeVM    文件:JSpinnerTest.java   
public void testDateEditor_formatter() {
    spinner.setModel(new SpinnerDateModel());
    DateEditor dateEditor = new DateEditor(spinner);
    spinner.setEditor(dateEditor);
    final Date date1 = new Date(777);
    DateFormatter dateFormatter = ((DateFormatter) dateEditor.getTextField().getFormatter());
    dateFormatter.setMaximum(date1);
    assertSame(dateFormatter.getMaximum(), date1);
    assertSame(dateEditor.getModel().getEnd(), date1);
    final Date date2 = new Date(555);
    dateEditor.getModel().setEnd(date2);
    assertSame(dateFormatter.getMaximum(), date2);
    assertSame(dateEditor.getModel().getEnd(), date2);
    SpinnerDateModel old = (SpinnerDateModel) spinner.getModel();
    spinner.setModel(abstractModel);
    final Date date3 = new Date(555);
    old.setEnd(date3);
    assertEquals(((DateFormatter) ((DateEditor) spinner.getEditor()).getTextField()
            .getFormatter()).getMaximum(), date3);
}
项目:wichtel    文件:FormatFactory.java   
/**
 * Creates a {@link DateFormatter} for display-mode from a given {@link DateFormat}.
 *
 * @param format for the formatter
 * @return created {@link DateFormatter}
 * @see DateFormat
 * @see DateFormatter
 * @since 0.0.1
 */
public static DateFormatter createDateFormatterDisplay(final DateFormat format) {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart(format));
    if (null == format) {
        throw new RuntimeExceptionIsNull("format"); //$NON-NLS-1$
    }

    final DateFormatter result = new DateFormatter(format) {
        private static final long serialVersionUID = 8705680761187261160L;

        {
            setCommitsOnValidEdit(true);
        }
    };

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit(result));
    return result;
}
项目:wichtel    文件:FormatFactory.java   
/**
 * Creates a {@link DateFormatter} for edit-mode from a given {@link DateFormat}.
 *
 * @param format for the formatter
 * @return created {@link DateFormatter}
 * @see DateFormat
 * @see DateFormatter
 * @since 0.0.1
 */
public static DateFormatter createDateFormatterEdit(final DateFormat format) {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart(format));
    if (null == format) {
        throw new RuntimeExceptionIsNull("format"); //$NON-NLS-1$
    }

    final DateFormatter result = new DateFormatter(format) {
        private static final long serialVersionUID = 8705680761187261160L;

        {
            setCommitsOnValidEdit(true);
        }
    };

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit(result));
    return result;
}
项目:JRLib    文件:MonthDateSpinner.java   
public MonthDateSpinner(MonthDate value, MonthDate min, MonthDate max) {
    super(new SpinnerDateModel(MDF.toDate(value), toDate(min), toDate(max), STEP_UNIT));
    SpinnerDateModel model = (SpinnerDateModel) super.getModel();
    minDate = (Date) model.getStart();
    maxDate = (Date) model.getEnd();

    JFormattedTextField text = ((JSpinner.DateEditor) getEditor()).getTextField();
    DateFormatter df = new DateFormatter(new SimpleDateFormat(PATTERN));
    text.setFormatterFactory(new DefaultFormatterFactory(df));
    text.setColumns(PATTERN.length());
    text.setEditable(false);
    text.setHorizontalAlignment(JTextField.RIGHT);

    revalidate();
    repaint();
}
项目:smile_1.5.0_java7    文件:DateCellEditor.java   
/**
 * Constructor.
 */
public DateCellEditor(DateFormat dateFormat) {
    super(new JFormattedTextField());
    textField = (JFormattedTextField) getComponent();

    this.dateFormat = dateFormat;
    DateFormatter dateFormatter = new DateFormatter(dateFormat);

    textField.setFormatterFactory(new DefaultFormatterFactory(dateFormatter));
    textField.setHorizontalAlignment(JTextField.TRAILING);
    textField.setFocusLostBehavior(JFormattedTextField.PERSIST);

    // React when the user presses Enter while the editor is
    // active.  (Tab is handled as specified by
    // JFormattedTextField's focusLostBehavior property.)
    textField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    textField.getActionMap().put("check", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!textField.isEditValid()) { //The text is invalid.
                Toolkit.getDefaultToolkit().beep();
                textField.selectAll();
            } else {
                try {              //The text is valid,
                    textField.commitEdit();     //so use it.
                    textField.postActionEvent(); //stop editing
                } catch (java.text.ParseException ex) {
                }
            }
        }
    });
}
项目:j2se_for_android    文件:JFormattedTextField.java   
/**
 * Returns an AbstractFormatterFactory suitable for the passed in Object
 * type.
 */
private AbstractFormatterFactory getDefaultFormatterFactory(Object type) {
    if (type instanceof DateFormat) {
        return new DefaultFormatterFactory(new DateFormatter(
                (DateFormat) type));
    }
    if (type instanceof NumberFormat) {
        return new DefaultFormatterFactory(new NumberFormatter(
                (NumberFormat) type));
    }
    if (type instanceof Format) {
        return new DefaultFormatterFactory(new InternationalFormatter(
                (Format) type));
    }
    if (type instanceof Date) {
        return new DefaultFormatterFactory(new DateFormatter());
    }
    if (type instanceof Number) {
        AbstractFormatter displayFormatter = new NumberFormatter();
        ((NumberFormatter) displayFormatter).setValueClass(type.getClass());
        AbstractFormatter editFormatter = new NumberFormatter(
                new DecimalFormat("#.#"));
        ((NumberFormatter) editFormatter).setValueClass(type.getClass());

        return new DefaultFormatterFactory(displayFormatter,
                displayFormatter, editFormatter);
    }
    return new DefaultFormatterFactory(new DefaultFormatter());
}
项目:JGrafix    文件:EixoHorizontalComLabels.java   
@Override
public List refreshTicks(Graphics2D g2, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge) {
    try {
        long l1 = this.getMaximumDate().getTime();
        long l2 = this.getMinimumDate().getTime();
        int diasExibidos = (int) ((l1 - l2) / ref);
        if (diasExibidos == diasExibidosAnterior && ticksAnteriores != null) {
            return ticksAnteriores; // otimizacao
        } else {
            List result = new ArrayList();
            int j = 0;
            for (int i = acao.getNumeroRegistros() - 1; i >= 0; i--) {
                int n = (int) (diasExibidos / QUANTIDADE_DATAS);
                if (j++ % n == 0) {
                    result.add(new DateTick(acao.getRegistro(i).getDataCorrida().getStart(),
                            new DateFormatter(new SimpleDateFormat("dd/MM/yy")).valueToString(acao.getRegistro(i).getData().getStart()),
                            TextAnchor.TOP_CENTER,
                            TextAnchor.TOP_RIGHT, 0));
                } else {
                    result.add(new DateTick(acao.getRegistro(i).getDataCorrida().getStart(),
                            "",
                            TextAnchor.TOP_CENTER,
                            TextAnchor.TOP_RIGHT, 0));
                }
            }
            ticksAnteriores = result;
            diasExibidosAnterior = diasExibidos;
            return result;
        }
    } catch (Exception e) {
        return new ArrayList();
    }
}
项目:swingx    文件:JXDatePickerVisualCheck.java   
/**
 * From forum: have spinner with the same timezone.
 */
public void interactiveTimeZoneFormat() {
    final JSpinner spinner = new JSpinner(new SpinnerDateModel());
    final JXDatePicker picker = new JXDatePicker();
    picker.setTimeZone(TimeZone.getTimeZone("GMT-10"));
    picker.setDate(new Date());
    spinner.setValue(picker.getDate());
    SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss", picker.getLocale());
    format.setTimeZone(picker.getTimeZone());
    JFormattedTextField textField = ((DefaultEditor) spinner.getEditor()).getTextField();
    textField.setFormatterFactory(
            new DefaultFormatterFactory(new DateFormatter(format)));
    PropertyChangeListener l = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if ("date".equals(evt.getPropertyName())) {
                if (picker.getDate() != null)
                 spinner.setValue(picker.getDate());
            }
        }

    };
    picker.addPropertyChangeListener(l);
    JXPanel panel = new JXPanel();
    panel.add(picker);
    panel.add(spinner);
    showInFrame(panel, "formats in picker and spinner");
}
项目:swingx    文件:JXDatePickerTest.java   
/**
 * Issue #1144-swingx: JXDatePicker must accept custom formatter.
 * Use core DateFormatter - issue manifests in throwing classcastEx
 */
@Test
public void testCustomFormatterCore() {
    JXDatePicker picker = new JXDatePicker();
    DefaultFormatterFactory factory = new DefaultFormatterFactory(new DateFormatter());
    picker.getEditor().setFormatterFactory(factory);
    picker.updateUI();
}
项目:jspresso-ce    文件:DefaultSwingViewFactory.java   
/**
 * {@inheritDoc}
 */
@Override
protected IView<JComponent> createDatePropertyView(IPropertyViewDescriptor propertyViewDescriptor,
                                                   IActionHandler actionHandler, Locale locale) {
  IDatePropertyDescriptor propertyDescriptor = (IDatePropertyDescriptor) propertyViewDescriptor.getModelDescriptor();
  IValueConnector connector;
  JComponent viewComponent;
  TimeZone timeZone =
      propertyDescriptor.isTimeZoneAware() ? actionHandler.getClientTimeZone() : actionHandler.getReferenceTimeZone();
  DateFormat format = createDateFormat(propertyViewDescriptor, propertyDescriptor, timeZone, actionHandler, locale);
  IFormatter<?, String> formatter = createFormatter(format);
  if (propertyViewDescriptor.isReadOnly()) {
    if (propertyViewDescriptor.getAction() != null) {
      viewComponent = createJLink(propertyViewDescriptor);
    } else {
      viewComponent = createJLabel(propertyViewDescriptor, true);
    }
    connector = new JLabelConnector(propertyDescriptor.getName(), (JLabel) viewComponent);
    ((JLabelConnector) connector).setFormatter(formatter);
  } else {
    viewComponent = createJDateField(propertyViewDescriptor, locale);
    ((JDateField) viewComponent).getFormattedTextField().setFormatterFactory(
        new DefaultFormatterFactory(new DateFormatter(format)));
    connector = new JDateFieldConnector(propertyDescriptor.getName(), (JDateField) viewComponent);
  }
  adjustSizes(propertyViewDescriptor, viewComponent, formatter, getDateTemplateValue(propertyDescriptor),
      Toolkit.getDefaultToolkit().getScreenResolution() / 3);
  connector.setExceptionHandler(actionHandler);
  IView<JComponent> view = constructView(viewComponent, propertyViewDescriptor, connector);
  return view;
}
项目:cn1    文件:JFormattedTextField.java   
private AbstractFormatterFactory createFactory(final Object value) {
    DefaultFormatterFactory factory = new DefaultFormatterFactory();
    if (value instanceof Number) {
        factory.setDefaultFormatter(new NumberFormatter());
    } else if (value instanceof Date) {
        factory.setDefaultFormatter(new DateFormatter());
    } else {
        factory.setDefaultFormatter(new DefaultFormatter());
    }
    return factory;
}
项目:cn1    文件:JFormattedTextField.java   
private AbstractFormatter createFormatter(final Format format) {
    if (format instanceof DateFormat) {
        return new DateFormatter((DateFormat) format);
    } else if (format instanceof NumberFormat) {
        return new NumberFormatter((NumberFormat) format);
    } else {
        return new InternationalFormatter(format);
    }
}
项目:snap-desktop    文件:DateTimePicker.java   
private void updateTextFieldFormat() {
    if (timeSpinner == null) {
        return;
    }
    JFormattedTextField tf = ((JSpinner.DefaultEditor) timeSpinner.getEditor()).getTextField();
    DefaultFormatterFactory factory = (DefaultFormatterFactory) tf.getFormatterFactory();
    DateFormatter formatter = (DateFormatter) factory.getDefaultFormatter();
    // Change the date format to only show the hours
    formatter.setFormat(timeFormat);
}
项目:nosql4idea    文件:DateTimePicker.java   
private void updateTextFieldFormat() {
    if (timeSpinner == null) return;
    JFormattedTextField tf = ((JSpinner.DefaultEditor) timeSpinner.getEditor()).getTextField();
    DefaultFormatterFactory factory = (DefaultFormatterFactory) tf.getFormatterFactory();
    DateFormatter formatter = (DateFormatter) factory.getDefaultFormatter();
    // Change the date format to only show the hours
    formatter.setFormat(timeFormat);
}
项目:freeVM    文件:JFormattedTextField.java   
private AbstractFormatterFactory createFactory(final Object value) {
    DefaultFormatterFactory factory = new DefaultFormatterFactory();
    if (value instanceof Number) {
        factory.setDefaultFormatter(new NumberFormatter());
    } else if (value instanceof Date) {
        factory.setDefaultFormatter(new DateFormatter());
    } else {
        factory.setDefaultFormatter(new DefaultFormatter());
    }
    return factory;
}
项目:freeVM    文件:JFormattedTextField.java   
private AbstractFormatter createFormatter(final Format format) {
    if (format instanceof DateFormat) {
        return new DateFormatter((DateFormat) format);
    } else if (format instanceof NumberFormat) {
        return new NumberFormatter((NumberFormat) format);
    } else {
        return new InternationalFormatter(format);
    }
}
项目:freeVM    文件:JSpinnerTest.java   
public void testDateEditor_formatter() {
    spinner.setModel(new SpinnerDateModel());
    DateEditor dateEditor = new DateEditor(spinner);
    spinner.setEditor(dateEditor);
    final Date date1 = new Date(777);
    DateFormatter dateFormatter = ((DateFormatter) dateEditor.getTextField().getFormatter());
    dateFormatter.setMaximum(date1);
    assertSame(dateFormatter.getMaximum(), date1);
    assertSame(dateEditor.getModel().getEnd(), date1);
    final Date date2 = new Date(555);
    dateEditor.getModel().setEnd(date2);
    assertSame(dateFormatter.getMaximum(), date2);
    assertSame(dateEditor.getModel().getEnd(), date2);
    SpinnerDateModel old = (SpinnerDateModel) spinner.getModel();
    spinner.setModel(abstractModel);
    final Date date3 = new Date(555);
    old.setEnd(date3);
    assertEquals(((DateFormatter) ((DateEditor) spinner.getEditor()).getTextField()
            .getFormatter()).getMaximum(), date3);
}
项目:freeVM    文件:JFormattedTextField.java   
private AbstractFormatterFactory createFactory(final Object value) {
    DefaultFormatterFactory factory = new DefaultFormatterFactory();
    if (value instanceof Number) {
        factory.setDefaultFormatter(new NumberFormatter());
    } else if (value instanceof Date) {
        factory.setDefaultFormatter(new DateFormatter());
    } else {
        factory.setDefaultFormatter(new DefaultFormatter());
    }
    return factory;
}
项目:freeVM    文件:JFormattedTextField.java   
private AbstractFormatter createFormatter(final Format format) {
    if (format instanceof DateFormat) {
        return new DateFormatter((DateFormat) format);
    } else if (format instanceof NumberFormat) {
        return new NumberFormatter((NumberFormat) format);
    } else {
        return new InternationalFormatter(format);
    }
}
项目:TechScore    文件:DetailsPane.java   
/**
 * Creates a new <code>DetailsPane</code> instance.
 *
 */
public DetailsPane(Regatta reg) {
  super("Details");
  this.setIcon(Factory.getImageIcon("img/Edit16.gif", this.toString()));
  this.df = new DateFormatter(DateFormat.getDateInstance(DateFormat.SHORT,
                       Locale.US));
  this.tf = new DateFormatter(DateFormat.getTimeInstance(DateFormat.SHORT,
                       Locale.US));
  this.setLayout(new GridBagLayout());
  this.setRegatta(reg);
}
项目:FTC-FieldMgmt    文件:myDateField.java   
public myDateField() {
    this.setValue(new Date());
    this.setFormatterFactory(new DefaultFormatterFactory(new DateFormatter(new SimpleDateFormat("yyyy-MM-dd HH:mm"))));
    this.setValue(Calendar.getInstance().getTime());

    this.addPropertyChangeListener("value", new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent evt) {

        }
    });
}
项目:jdk8u-jdk    文件:Test6462562.java   
TestFormattedTextField create(DateFormat format) {
    DateFormatter fmt = new DateFormatter(format);
    return new TestFormattedTextField(fmt);
}
项目:openjdk-jdk10    文件:Test6462562.java   
TestFormattedTextField create(DateFormat format) {
    DateFormatter fmt = new DateFormatter(format);
    return new TestFormattedTextField(fmt);
}
项目:openjdk9    文件:Test6462562.java   
TestFormattedTextField create(DateFormat format) {
    DateFormatter fmt = new DateFormatter(format);
    return new TestFormattedTextField(fmt);
}
项目:jdk8u_jdk    文件:Test6462562.java   
TestFormattedTextField create(DateFormat format) {
    DateFormatter fmt = new DateFormatter(format);
    return new TestFormattedTextField(fmt);
}
项目:lookaside_java-1.8.0-openjdk    文件:Test6462562.java   
TestFormattedTextField create(DateFormat format) {
    DateFormatter fmt = new DateFormatter(format);
    return new TestFormattedTextField(fmt);
}
项目:swingx    文件:DatePickerDemo.java   
private void configureComponents() {
    dateEchoField.setEditable(false);
    AbstractFormatter formatter = new DateFormatter(DateFormat.getDateTimeInstance());
    AbstractFormatterFactory tf = new DefaultFormatterFactory(formatter);
    dateEchoField.setFormatterFactory(tf);
}
项目:tellervo    文件:BasicDatePickerUI.java   
private DefaultFormatterFactory createFormatterFactory() {
    return new DefaultFormatterFactory(new DateFormatter(peer
            .getDateFormat()));
}
项目:infobip-open-jdk-8    文件:Test6462562.java   
TestFormattedTextField create(DateFormat format) {
    DateFormatter fmt = new DateFormatter(format);
    return new TestFormattedTextField(fmt);
}