Java 类javax.swing.SpinnerDateModel 实例源码

项目:snap-desktop    文件:DateTimePicker.java   
private JPanel createTimePanel() {
    JPanel newPanel = new JPanel();
    newPanel.setLayout(new FlowLayout());
    Date date = getDate();
    if (date == null) {
        Calendar calendar = Calendar.getInstance(timeZone);
        date = calendar.getTime();
    }
    SpinnerDateModel dateModel = new SpinnerDateModel(date, null, null, Calendar.DAY_OF_MONTH);
    timeSpinner = new JSpinner(dateModel);
    if (timeFormat == null) {
        timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT);
    }
    updateTextFieldFormat();
    newPanel.add(new JLabel("Time:"));
    newPanel.add(timeSpinner);
    newPanel.setBackground(Color.WHITE);
    return newPanel;
}
项目:marathonv5    文件:JSpinnerJavaElementTest.java   
private JSpinner createDateSpinner(Calendar calendar) {
    Date initDate = calendar.getTime();
    calendar.add(Calendar.YEAR, -100);
    Date earliestDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 200);
    Date latestDate = calendar.getTime();
    SpinnerDateModel spinnerDateModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.YEAR);
    JSpinner dateSpinner = new JSpinner(spinnerDateModel);
    dateSpinner.setEditor(new JSpinner.DateEditor(dateSpinner, "MM/yyyy"));
    dateSpinner.setName("date-spinner");
    return dateSpinner;
}
项目:openjdk-jdk10    文件:bug8008657.java   
static void createDateSpinner() {
    Calendar calendar = Calendar.getInstance();
    Date initDate = calendar.getTime();
    calendar.add(Calendar.YEAR, -1);
    Date earliestDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 1);
    Date latestDate = calendar.getTime();
    SpinnerModel dateModel = new SpinnerDateModel(initDate,
            earliestDate,
            latestDate,
            Calendar.YEAR);
    spinner = new JSpinner();
    spinner.setModel(dateModel);
}
项目:javify    文件:SpinnerDemo.java   
private JPanel createPanel2()
{
  JPanel panel = new JPanel(new BorderLayout());
  this.spinnerState2 = new JCheckBox("Enabled", true);
  this.spinnerState2.setActionCommand("COMBO_STATE2");
  this.spinnerState2.addActionListener(this);
  panel.add(this.spinnerState2, BorderLayout.EAST);

  JPanel controlPanel = new JPanel();
  controlPanel.setBorder(BorderFactory.createTitledBorder("Date Spinner: "));
  this.spinner3 = new JSpinner(new SpinnerDateModel(new Date(), null, null,
      Calendar.DATE));

  this.spinner4 = new JSpinner(new SpinnerDateModel(new Date(), null, null,
      Calendar.YEAR));
  this.spinner4.setFont(new Font("Dialog", Font.PLAIN, 20));

  controlPanel.add(this.spinner3);
  controlPanel.add(this.spinner4);

  panel.add(controlPanel);

  return panel;
}
项目:code-similarity    文件:SpinnerDemo.java   
public static void main(String[] args) {
    JFrame jf = new JFrame("It Spins");
    Container cp = jf.getContentPane();
    cp.setLayout(new GridLayout(0,1));

    // Create a JSpinner using one of the pre-defined SpinnerModels
    JSpinner dates = new JSpinner(new SpinnerDateModel());
    cp.add(dates);

    // Create a JSPinner using a SpinnerListModel. 
    String[] data = { "One", "Two", "Three" };
    JSpinner js = new JSpinner(new SpinnerListModel(data));
    cp.add(js);

    jf.setSize(100, 80);
    jf.setVisible(true);
}
项目:SWAT20    文件:TimeFilterDialog.java   
public DatePickerPanel(Date date) {
        super(new FlowLayout());

        this.date = date;

        // is null checkbox
        cbIsNull = new JCheckBox();
        cbIsNull.setToolTipText("is null?");

        // date text field
        smDateModel = new SpinnerDateModel();
        spDate = new JSpinner(smDateModel);

        cbIsNull.setSelected(date == null);
        spDate.setEnabled(date != null);
        if (date != null) {
                smDateModel.setValue(date);
        }

        cbIsNull.addItemListener(new CheckboxListener());
        spDate.addChangeListener(new DatePickerListener());

        add(cbIsNull);
        add(spDate);
}
项目:jvm-stm    文件:SpinnerDemo.java   
private JPanel createPanel2() 
{
  JPanel panel = new JPanel(new BorderLayout());
  this.spinnerState2 = new JCheckBox("Enabled", true);
  this.spinnerState2.setActionCommand("COMBO_STATE2");
  this.spinnerState2.addActionListener(this);
  panel.add(this.spinnerState2, BorderLayout.EAST);

  JPanel controlPanel = new JPanel();
  controlPanel.setBorder(BorderFactory.createTitledBorder("Date Spinner: "));
  this.spinner3 = new JSpinner(new SpinnerDateModel(new Date(), null, null, 
      Calendar.DATE));

  this.spinner4 = new JSpinner(new SpinnerDateModel(new Date(), null, null, 
      Calendar.YEAR));
  this.spinner4.setFont(new Font("Dialog", Font.PLAIN, 20));

  controlPanel.add(this.spinner3);
  controlPanel.add(this.spinner4);

  panel.add(controlPanel);

  return panel;
}
项目:swingx    文件:JXDatePickerIssues.java   
/**
 * Issue #913-swingx: Datepicker looks bad in some LFs (f.i. Nimbus)
 * 
 * not only Nimbus ...
 * - Metal: starts with different height than textfield, shrinks when coming
 *   back from another LF
 * - motif: button is shrunkenn always
 * - win: halfway okay, but should have buttons "nearer/integrated" to the field
 *   as spinner, combo does
 * - Vista: button should visually "merge" into field until rollover (as combo does,
 *   Spinner not
 * - Can't remember the reason why combo's button isn't re-used?
 *       
 */
public void interactiveDatePickerNimbus() {
    JXDatePicker picker = new JXDatePicker(new Date());
    JFormattedTextField field = new JFormattedTextField();
    field.setValue(picker.getDate());
    JSpinner spinner = new JSpinner(new SpinnerDateModel());
    spinner.setValue(picker.getDate());
    JComboBox box = new JComboBox(new Object[] {picker.getDate()});
    box.setEditable(true);
    JComponent panel = new JXPanel();
    panel.add(field);
    panel.add(picker);
    panel.add(spinner);
    panel.add(box);
    showInFrame(panel, "Nimbus and picker");
}
项目:kgsview    文件:DateFilterPanel.java   
public DateFilterPanel() {
    filter = new DateFilter();

    firstModel = new SpinnerDateModel();
    lastModel = new SpinnerDateModel();
    beforeModel = new SpinnerDateModel();
    afterModel = new SpinnerDateModel();
    daysModel = new SpinnerNumberModel(1, 0, 3000, 1);

    initComponents();

    firstSpinner.setModel(firstModel);
    lastSpinner.setModel(lastModel);
    beforeSpinner.setModel(beforeModel);
    afterSpinner.setModel(afterModel);
    daysSpinner.setModel(daysModel);

    firstSpinner.setEditor(new JSpinner.DateEditor(firstSpinner, "yyyy/MM/dd"));
    lastSpinner.setEditor(new JSpinner.DateEditor(lastSpinner, "yyyy/MM/dd"));
    beforeSpinner.setEditor(new JSpinner.DateEditor(beforeSpinner, "yyyy/MM/dd"));
    afterSpinner.setEditor(new JSpinner.DateEditor(afterSpinner, "yyyy/MM/dd"));

    setDateFilter(filter);
}
项目:hipster    文件:XMLPanel.java   
private static JSpinner makeDate(Controller c, String source,
        GridBagLayout gbl, GridBagConstraints con) {
    JSpinner dt = new JSpinner();
    SpinnerModel sm = new SpinnerDateModel();
    dt.setModel(sm);
    JSpinner.DateEditor editor = (JSpinner.DateEditor)dt.getEditor();
    JTextField txt = editor.getTextField();
    txt.setForeground(Color.WHITE);
    txt.setBackground(new Color(55, 55, 55));
    txt.setCaretColor(Color.WHITE);
    gbl.setConstraints(dt, con);
    if (source.startsWith("#")) {
        c.bind(dt, source.substring(1));
    } else {
        dt.setValue(source);
    }
    return dt;
}
项目:JamVM-PH    文件:SpinnerDemo.java   
private JPanel createPanel2() 
{
  JPanel panel = new JPanel(new BorderLayout());
  this.spinnerState2 = new JCheckBox("Enabled", true);
  this.spinnerState2.setActionCommand("COMBO_STATE2");
  this.spinnerState2.addActionListener(this);
  panel.add(this.spinnerState2, BorderLayout.EAST);

  JPanel controlPanel = new JPanel();
  controlPanel.setBorder(BorderFactory.createTitledBorder("Date Spinner: "));
  this.spinner3 = new JSpinner(new SpinnerDateModel(new Date(), null, null, 
      Calendar.DATE));

  this.spinner4 = new JSpinner(new SpinnerDateModel(new Date(), null, null, 
      Calendar.YEAR));
  this.spinner4.setFont(new Font("Dialog", Font.PLAIN, 20));

  controlPanel.add(this.spinner3);
  controlPanel.add(this.spinner4);

  panel.add(controlPanel);

  return panel;
}
项目:classpath    文件:SpinnerDemo.java   
private JPanel createPanel2()
{
  JPanel panel = new JPanel(new BorderLayout());
  this.spinnerState2 = new JCheckBox("Enabled", true);
  this.spinnerState2.setActionCommand("COMBO_STATE2");
  this.spinnerState2.addActionListener(this);
  panel.add(this.spinnerState2, BorderLayout.EAST);

  JPanel controlPanel = new JPanel();
  controlPanel.setBorder(BorderFactory.createTitledBorder("Date Spinner: "));
  this.spinner3 = new JSpinner(new SpinnerDateModel(new Date(), null, null,
      Calendar.DATE));

  this.spinner4 = new JSpinner(new SpinnerDateModel(new Date(), null, null,
      Calendar.YEAR));
  this.spinner4.setFont(new Font("Dialog", Font.PLAIN, 20));

  controlPanel.add(this.spinner3);
  controlPanel.add(this.spinner4);

  panel.add(controlPanel);

  return panel;
}
项目:jhylafax    文件:AbstractFaxDialog.java   
protected void addDateControls() {
    dateNowRadionButton = new JRadioButton();
    dateNowRadionButton.setSelected(true);
    dateLabel = builder.append("", dateNowRadionButton);
    builder.nextLine();

    dateLaterRadionButton = new JRadioButton();
    dateModel = new SpinnerDateModel();
    final JSpinner dateSpinner = new JSpinner(dateModel);
    dateSpinner.setEnabled(false);
    dateLaterRadionButton.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            dateSpinner.setEnabled(dateLaterRadionButton.isSelected());
        }           
    });
    builder.append("", dateLaterRadionButton, dateSpinner);
    builder.nextLine();

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(dateNowRadionButton);
    buttonGroup.add(dateLaterRadionButton);     
}
项目:TechScore    文件:RPDatabasePane.java   
public DatabaseRow(String aff, Membership member) {
  this.sailor = member;
  this.affiliation = aff;
  this.editable = member.isNew();
  this.nameField = new JTextField(member.getName());
  this.nameField.setEditable(this.editable);
  // Year
  SpinnerDateModel sm = new SpinnerDateModel(member.getYear(),
         null,
         null,
         Calendar.YEAR);
  this.yearSpinner = new JSpinner(sm);
  yearSpinner.setEditor(new JSpinner.DateEditor(yearSpinner,
            "yyyy"));
  this.yearSpinner.setEnabled(this.editable);
  // Edit and delete buttons
  this.delBut = Factory.tightButton(new DelSailorAction());
  this.editBut= Factory.tightButton(new EditSailorAction());
}
项目:TechScore    文件:RPDatabasePane.java   
/**
 * Creates a new empty <code>DatabaseRow</code> instance, perfect
 * to add to the database.
 *
 */
public DatabaseRow(String aff) {
  this.affiliation = aff;
  this.sailor = null;
  this.nameField = new JTextField();
  this.editable  = true;
  // Year
  SpinnerDateModel sm = new SpinnerDateModel(new Date(),
         null,
         null,
         Calendar.YEAR);
  this.yearSpinner = new JSpinner(sm);
  yearSpinner.setEditor(new JSpinner.DateEditor(yearSpinner,
            "yyyy"));
  // Add Button
  this.addBut = Factory.tightButton(new AddSailorAction());
}
项目:sos-importer    文件:MissingDatePanel.java   
public MissingDatePanel(DateAndTime dateAndTime) {
    super(dateAndTime);
    GregorianCalendar calendar = new GregorianCalendar();
    Date initDate = calendar.getTime();
    calendar.add(Calendar.YEAR, -100);
    Date earliestDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 200);
    Date latestDate = calendar.getTime();
    dateModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.YEAR);
    dateSpinner = new JSpinner(dateModel);
    dateSpinner.setEditor(new JSpinner.DateEditor(dateSpinner, "yyyy-MM-dd"));

    this.setLayout(new FlowLayout(FlowLayout.LEFT));
    this.add(dateLabel);
    this.add(dateSpinner);
}
项目:sos-importer    文件:MissingTimePanel.java   
public MissingTimePanel(DateAndTime dateAndTime) {
    super(dateAndTime);
    timeModel = new SpinnerDateModel();
    GregorianCalendar gc = new GregorianCalendar(0, 0, 0, 0, 0, 0);
    timeModel.setValue(gc.getTime());
    timeModel.setCalendarField(Calendar.HOUR_OF_DAY);
    timeSpinner = new JSpinner(timeModel);
    timeSpinner.setEditor(new JSpinner.DateEditor(timeSpinner, "HH:mm:ss"));

    this.setLayout(new FlowLayout(FlowLayout.LEFT));

    this.timeLabel = new JLabel(Lang.l().time() + ": ");

    this.add(timeLabel);
    this.add(timeSpinner);
}
项目: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();
}
项目:JRLib    文件:InputDataEditorPanel.java   
private void initSpinnerModels() {
    Calendar calendar = initCalendar();
    Date endNow = calendar.getTime();
    calendar.add(Calendar.YEAR, -8);
    Date startNow = calendar.getTime();

    calendar.set(Calendar.MONTH, Calendar.JANUARY);
    calendar.add(Calendar.YEAR, -92);
    Date minDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 200);
    Date maxDate = calendar.getTime();


    startDateModel = new SpinnerDateModel(startNow, minDate, maxDate, Calendar.MONTH);
    endDateModel = new SpinnerDateModel(endNow, minDate, maxDate, Calendar.MONTH);
}
项目:Equella    文件:FlatterSpinnerUI.java   
@Override
public void actionPerformed(ActionEvent e)
{
    JSpinner locSpinner = this.spinner;

    if( !(e.getSource() instanceof javax.swing.Timer) )
    {
        // Most likely resulting from being in ActionMap.
        locSpinner = eventToSpinner(e);
    }
    if( locSpinner != null )
    {
        try
        {
            int calendarField = getCalendarField(locSpinner);
            locSpinner.commitEdit();
            if( calendarField != -1 )
            {
                ((SpinnerDateModel) locSpinner.getModel()).setCalendarField(calendarField);
            }
            Object value = (isNext) ? locSpinner.getNextValue() : locSpinner.getPreviousValue();
            if( value != null )
            {
                locSpinner.setValue(value);
                select(locSpinner);
            }
        }
        catch( IllegalArgumentException iae )
        {
            UIManager.getLookAndFeel().provideErrorFeedback(locSpinner);
        }
        catch( ParseException pe )
        {
            UIManager.getLookAndFeel().provideErrorFeedback(locSpinner);
        }
    }
}
项目:Equella    文件:FlatterSpinnerUI.java   
/**
 * If the spinner's editor is a DateEditor, this selects the field
 * associated with the value that is being incremented.
 */
private void select(JSpinner spinner)
{
    JComponent editor = spinner.getEditor();

    if( editor instanceof JSpinner.DateEditor )
    {
        JSpinner.DateEditor dateEditor = (JSpinner.DateEditor) editor;
        JFormattedTextField ftf = dateEditor.getTextField();
        Format format = dateEditor.getFormat();
        Object value = spinner.getValue();

        if( format != null && value != null )
        {
            SpinnerDateModel model = dateEditor.getModel();
            DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField());

            if( field != null )
            {
                try
                {
                    AttributedCharacterIterator iterator = format.formatToCharacterIterator(value);
                    if( !select(ftf, iterator, field) && field == DateFormat.Field.HOUR0 )
                    {
                        select(ftf, iterator, DateFormat.Field.HOUR1);
                    }
                }
                catch( IllegalArgumentException iae )
                {
                    // ??
                }
            }
        }
    }
}
项目:zooracle    文件:ComparePanel.java   
public ComparePanel()
{
    dateSpinner = new JSpinner( new SpinnerDateModel() );
    JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(dateSpinner, "dd.MM.yyyy");
    dateSpinner.setEditor(dateEditor);
    dateSpinner.setValue(new Date()); 
    timeSpinner = new JSpinner( new SpinnerDateModel() );
    JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "HH:mm:ss");
    timeSpinner.setEditor(timeEditor);
    timeSpinner.setValue(new Date()); 

}
项目:Cognizant-Intelligent-Test-Scripter    文件:SchedulerUI.java   
private void initDateModel() {
    SpinnerDateModel dmodel = new SpinnerDateModel();
    dateSpinner.setModel(dmodel);
    dateSpinner.setEditor(new JSpinner.DateEditor(dateSpinner, "MMM - dd - yyyy"));

    SpinnerDateModel tmodel = new SpinnerDateModel();
    timeSpinner.setModel(tmodel);
    timeSpinner.setEditor(new JSpinner.DateEditor(timeSpinner, "HH:mm"));
}
项目:jdk8u-jdk    文件:bug6463712.java   
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
项目:openjdk-jdk10    文件:bug6463712.java   
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
项目:openjdk-jdk10    文件:JSpinnerOperator.java   
/**
 * Returns a minimal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a minimal value.
 *
 * @return a minimal value.
 */
public Object getMinimum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMinimum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
项目:openjdk-jdk10    文件:JSpinnerOperator.java   
/**
 * Returns a maximal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a maximal value.
 *
 * @return a maximal value.
 */
public Object getMaximum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMaximum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
项目:openjdk9    文件:bug8008657.java   
static void createDateSpinner() {
    Calendar calendar = Calendar.getInstance();
    Date initDate = calendar.getTime();
    calendar.add(Calendar.YEAR, -1);
    Date earliestDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 1);
    Date latestDate = calendar.getTime();
    SpinnerModel dateModel = new SpinnerDateModel(initDate,
            earliestDate,
            latestDate,
            Calendar.YEAR);
    spinner = new JSpinner();
    spinner.setModel(dateModel);
}
项目:openjdk9    文件:bug6463712.java   
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
项目:openjdk9    文件:JSpinnerOperator.java   
/**
 * Returns a minimal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a minimal value.
 *
 * @return a minimal value.
 */
public Object getMinimum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMinimum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
项目:openjdk9    文件:JSpinnerOperator.java   
/**
 * Returns a maximal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a maximal value.
 *
 * @return a maximal value.
 */
public Object getMaximum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMaximum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
项目:DigitalMediaServer    文件:CustomJSpinner.java   
@Override
protected JComponent createEditor(SpinnerModel model) {
    if (model instanceof SpinnerDateModel) {
        return new DateEditor(this);
    } else if (model instanceof SpinnerNumberModel) {
        return new NumberEditor(this);
    } else if (model instanceof SpinnerListModel) {
        return new ListEditor(this);
    } else if (model instanceof SpinnerIntModel) {
        return new IntegerEditor(this);
    } else {
        return new DefaultEditor(this);
    }
}
项目:netbeansplugins    文件:LocaleDatePanel.java   
/**
 * Set a Date value of the currently active SpinnerModel
 */
private void setDateSpinnerValue(Date date) {
    SpinnerModel sm = this.dateSpinner.getModel();
    if (sm instanceof SpinnerNumberModel) {
        sm.setValue(date.getTime());
    } else if (sm instanceof SpinnerDateModel) {
        sm.setValue(date);
    }
}
项目:netbeansplugins    文件:LocaleDatePanel.java   
/**
 * Get a Date value from the currently active SpinnerModel
 */
private Date getDateSpinnerValue() {
    Date date = new Date();

    SpinnerModel sm = this.dateSpinner.getModel();
    if (sm instanceof SpinnerNumberModel) {
        Long value = (Long) sm.getValue();
        date.setTime(value);
    } else if (sm instanceof SpinnerDateModel) {
        date = (Date) sm.getValue();
    }
    return date;
}
项目:netbeansplugins    文件:LocaleDatePanel.java   
/**
 * Apply a SpinnerDateModel to the jspinner component
 */
private void applySpinnerDateModel(JSpinner jspinner) {
    SpinnerDateModel spm = new SpinnerDateModel();
    jspinner.setModel(spm);
    jspinner.setEnabled(true);

    JSpinner.DateEditor jsde = (JSpinner.DateEditor) jspinner.getEditor();
    jsde.getFormat().applyPattern("yyyy:MM:dd HH:mm:ss.SSS");

}
项目:jdk8u_jdk    文件:bug6463712.java   
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
项目:lookaside_java-1.8.0-openjdk    文件:bug6463712.java   
public bug6463712() {
    SpinnerNumberModel m1 = new SpinnerNumberModel();
    JSpinner s = new JSpinner(m1);
    s.addChangeListener(this);
    SpinnerDateModel m2 = new SpinnerDateModel();
    s.setModel(m2);

    // m1 is no longer linked to the JSpinner (it has been replaced by m2), so
    // the following should not trigger a call to our stateChanged() method...
    m1.setValue(new Integer(1));
}
项目:xdm    文件:ConfigDialog.java   
Box createSchedulerPanel() {
   Box box = Box.createVerticalBox();
   box.setOpaque(false);
   box.setBorder(new EmptyBorder(10, 0, 0, 10));
   Box b0 = Box.createHorizontalBox();
   this.schedule = new JCheckBox(this.getString("LBL_Q"));
   this.schedule.setContentAreaFilled(false);
   this.schedule.setFocusPainted(false);
   b0.add(this.schedule);
   b0.setBorder(new EmptyBorder(0, 0, 10, 0));
   b0.add(Box.createHorizontalGlue());
   box.add(b0);
   this.start = new SpinnerDateModel();
   this.end = new SpinnerDateModel();
   this.startDate = new JSpinner(this.start);
   this.startDate.setEditor(new DateEditor(this.startDate, "dd-MMM-yy hh:mm a"));
   this.startDate.setMaximumSize(this.startDate.getPreferredSize());
   this.endDate = new JSpinner(this.end);
   this.endDate.setEditor(new DateEditor(this.endDate, "dd-MMM-yy hh:mm a"));
   this.endDate.setMaximumSize(this.endDate.getPreferredSize());
   Box b1 = Box.createHorizontalBox();
   b1.add(new JLabel(this.getString("LBL_START_Q")));
   b1.add(Box.createHorizontalGlue());
   b1.add(this.startDate);
   box.add(b1);
   box.add(Box.createRigidArea(new Dimension(10, 10)));
   Box b2 = Box.createHorizontalBox();
   b2.add(new JLabel(this.getString("LBL_STOP_Q")));
   b2.add(Box.createHorizontalGlue());
   b2.add(this.endDate);
   box.add(b2);
   return box;
}
项目: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");
}
项目:MeteoInfoLib    文件:JSpinnerDateEditor.java   
public JSpinnerDateEditor() {
    super(new SpinnerDateModel());
    dateFormatter = (SimpleDateFormat) DateFormat
            .getDateInstance(DateFormat.MEDIUM);
    ((JSpinner.DateEditor) getEditor()).getTextField().addFocusListener(
            this);
    DateUtil dateUtil = new DateUtil();
    setMinSelectableDate(dateUtil.getMinSelectableDate());
    setMaxSelectableDate(dateUtil.getMaxSelectableDate());
    ((JSpinner.DateEditor)getEditor()).getTextField().setFocusLostBehavior(JFormattedTextField.PERSIST);
    addChangeListener(this);
}