Java 类javax.swing.JSpinner.DateEditor 实例源码
项目:dsworkbench
文件:ClockFrame.java
/**
* Creates new form ClockFrame
*/
ClockFrame() {
initComponents();
jSpinner1.setValue(new Date(System.currentTimeMillis()));
((DateEditor) jSpinner1.getEditor()).getFormat().applyPattern("dd.MM.yy HH:mm:ss.SSS");
tThread = new TimerThread(this);
tThread.start();
jCheckBox1.setSelected(GlobalOptions.getProperties().getBoolean("clock.alwaysOnTop"));
setAlwaysOnTop(jCheckBox1.isSelected());
cp = new ColoredProgressBar(0, 1000);
jPanel1.add(cp, BorderLayout.CENTER);
jComboBox1.setModel(new DefaultComboBoxModel(new String[]{"Alarm", "Homer", "LetsGo", "NHL", "Roadrunner", "Schwing", "Sirene", "StarTrek1", "StarTrek2"}));
// <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
if (!Constants.DEBUG) {
GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.clock_tool", GlobalOptions.getHelpBroker().getHelpSet());
}
restoreTimers();
// </editor-fold>
}
项目:platypus-js
文件:JCalendarComboBox.java
@Override
public void setOpaque(boolean aValue) {
super.setOpaque(aValue);
if (_spinner != null) {
_spinner.setOpaque(aValue);
JComponent editor = _spinner.getEditor();
if (editor != null) {
editor.setOpaque(aValue);
if (editor instanceof DateEditor) {
if (((DateEditor) editor).getTextField() != null) {
((DateEditor) editor).getTextField().setOpaque(aValue);
}
}
}
}
}
项目:cn1
文件:BasicSpinnerKeyboardActions.java
public void actionPerformed(final ActionEvent e) {
JSpinner spinner = (JSpinner)e.getSource();
if (spinner.getEditor() instanceof DateEditor) {
DateEditor dateEditor = (DateEditor)spinner.getEditor();
JFormattedTextField textField = dateEditor.getTextField();
int calendarField = getCalendarField(textField);
dateEditor.getModel().setCalendarField(calendarField);
nextValue(spinner);
selectCalendarField(textField, calendarField);
} else {
nextValue(spinner);
}
}
项目: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
文件:BasicSpinnerKeyboardActions.java
public void actionPerformed(final ActionEvent e) {
JSpinner spinner = (JSpinner)e.getSource();
if (spinner.getEditor() instanceof DateEditor) {
DateEditor dateEditor = (DateEditor)spinner.getEditor();
JFormattedTextField textField = dateEditor.getTextField();
int calendarField = getCalendarField(textField);
dateEditor.getModel().setCalendarField(calendarField);
nextValue(spinner);
selectCalendarField(textField, calendarField);
} else {
nextValue(spinner);
}
}
项目: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
文件:BasicSpinnerKeyboardActions.java
public void actionPerformed(final ActionEvent e) {
JSpinner spinner = (JSpinner)e.getSource();
if (spinner.getEditor() instanceof DateEditor) {
DateEditor dateEditor = (DateEditor)spinner.getEditor();
JFormattedTextField textField = dateEditor.getTextField();
int calendarField = getCalendarField(textField);
dateEditor.getModel().setCalendarField(calendarField);
nextValue(spinner);
selectCalendarField(textField, calendarField);
} else {
nextValue(spinner);
}
}
项目: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);
}
项目: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());
}
项目: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;
}
项目:platypus-js
文件:JCalendarComboBox.java
public void setEditable(boolean aEditable) {
editable = aEditable;
if (_spinner != null && _spinner.getEditor() instanceof JSpinner.DateEditor) {
JSpinner.DateEditor dEditor = (JSpinner.DateEditor) _spinner.getEditor();
if (dEditor != null && dEditor.getTextField() != null) {
dEditor.getTextField().setEditable(editable);
}
}
if (_spinner != null) {
_spinner.setEnabled(editable && isEnabled());
}
if (_dropDownButton != null) {
_dropDownButton.setEnabled(editable && isEnabled());
}
}
项目:platypus-js
文件:JCalendarComboBox.java
@Override
public void setBackground(Color bg) {
super.setBackground(bg);
if (_spinner != null) {
_spinner.setBackground(bg);
if (_spinner.getEditor() != null && _spinner.getEditor() instanceof JSpinner.DateEditor) {
JSpinner.DateEditor de = (JSpinner.DateEditor) _spinner.getEditor();
if (de.getTextField() != null) {
de.getTextField().setBackground(bg);
}
}
}
}
项目:platypus-js
文件:JCalendarComboBox.java
@Override
public void setForeground(Color fg) {
super.setForeground(fg);
if (_spinner != null) {
_spinner.setForeground(fg);
if (_spinner.getEditor() != null && _spinner.getEditor() instanceof JSpinner.DateEditor) {
JSpinner.DateEditor de = (JSpinner.DateEditor) _spinner.getEditor();
if (de.getTextField() != null) {
de.getTextField().setForeground(fg);
}
}
}
}
项目:cn1
文件:BasicSpinnerKeyboardActions.java
public void actionPerformed(final ActionEvent e) {
JSpinner spinner = (JSpinner)e.getSource();
if (spinner.getEditor() instanceof DateEditor) {
DateEditor dateEditor = (DateEditor)spinner.getEditor();
JFormattedTextField textField = dateEditor.getTextField();
int calendarField = getCalendarField(textField);
dateEditor.getModel().setCalendarField(calendarField);
previousValue(spinner);
selectCalendarField(textField, calendarField);
} else {
previousValue(spinner);
}
}
项目:cn1
文件:JSpinnerTest.java
public void testCreateEditor() {
SpinnerModel model = new SpinnerNumberModel();
spinner.setModel(model);
assertTrue(spinner.createEditor(model) instanceof JSpinner.NumberEditor);
model = new SpinnerDateModel();
spinner.setModel(model);
assertTrue(spinner.createEditor(model) instanceof JSpinner.DateEditor);
model = new SpinnerListModel();
spinner.setModel(model);
assertTrue(spinner.createEditor(model) instanceof JSpinner.ListEditor);
assertTrue(spinner.createEditor(abstractModel) instanceof JSpinner.DefaultEditor);
}
项目:freeVM
文件:BasicSpinnerKeyboardActions.java
public void actionPerformed(final ActionEvent e) {
JSpinner spinner = (JSpinner)e.getSource();
if (spinner.getEditor() instanceof DateEditor) {
DateEditor dateEditor = (DateEditor)spinner.getEditor();
JFormattedTextField textField = dateEditor.getTextField();
int calendarField = getCalendarField(textField);
dateEditor.getModel().setCalendarField(calendarField);
previousValue(spinner);
selectCalendarField(textField, calendarField);
} else {
previousValue(spinner);
}
}
项目:freeVM
文件:JSpinnerTest.java
public void testCreateEditor() {
SpinnerModel model = new SpinnerNumberModel();
spinner.setModel(model);
assertTrue(spinner.createEditor(model) instanceof JSpinner.NumberEditor);
model = new SpinnerDateModel();
spinner.setModel(model);
assertTrue(spinner.createEditor(model) instanceof JSpinner.DateEditor);
model = new SpinnerListModel();
spinner.setModel(model);
assertTrue(spinner.createEditor(model) instanceof JSpinner.ListEditor);
assertTrue(spinner.createEditor(abstractModel) instanceof JSpinner.DefaultEditor);
}
项目: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
文件:BasicSpinnerKeyboardActions.java
public void actionPerformed(final ActionEvent e) {
JSpinner spinner = (JSpinner)e.getSource();
if (spinner.getEditor() instanceof DateEditor) {
DateEditor dateEditor = (DateEditor)spinner.getEditor();
JFormattedTextField textField = dateEditor.getTextField();
int calendarField = getCalendarField(textField);
dateEditor.getModel().setCalendarField(calendarField);
previousValue(spinner);
selectCalendarField(textField, calendarField);
} else {
previousValue(spinner);
}
}
项目:freeVM
文件:JSpinnerTest.java
public void testCreateEditor() {
SpinnerModel model = new SpinnerNumberModel();
spinner.setModel(model);
assertTrue(spinner.createEditor(model) instanceof JSpinner.NumberEditor);
model = new SpinnerDateModel();
spinner.setModel(model);
assertTrue(spinner.createEditor(model) instanceof JSpinner.DateEditor);
model = new SpinnerListModel();
spinner.setModel(model);
assertTrue(spinner.createEditor(model) instanceof JSpinner.ListEditor);
assertTrue(spinner.createEditor(abstractModel) instanceof JSpinner.DefaultEditor);
}
项目:nmonvisualizer
文件:LineChartAnnotationDialog.java
@Override
public void stateChanged(ChangeEvent e) {
// for xAxisTime
if (useXAxisValue.isSelected()) {
annotation.setText(((DateEditor) xAxisTime.getEditor()).getFormat().format(xAxisTime.getValue()));
}
}
项目:nmonvisualizer
文件:IOStatPostParser.java
protected void addComponents(JPanel content, GridBagConstraints labelConstraints,
GridBagConstraints fieldConstraints) {
date = new JSpinner(new SpinnerDateModel(new Date(TimeHelper.today()), null, null, Calendar.DAY_OF_WEEK));
date.setEditor(new DateEditor(date, "MMM dd yyyy"));
JLabel dateLabel = new JLabel("Date:");
dateLabel.setFont(Styles.LABEL);
dateLabel.setHorizontalAlignment(SwingConstants.TRAILING);
content.add(dateLabel, labelConstraints);
content.add(date, fieldConstraints);
}
项目:platypus-js
文件:JCalendarComboBox.java
public JFormattedTextField getEditorComponent() {
if (_spinner.getEditor() instanceof JSpinner.DateEditor) {
return ((JSpinner.DateEditor) _spinner.getEditor()).getTextField();
}
return null;
}
项目:nmonvisualizer
文件:AbsoluteTimeIntervalPanel.java
AbsoluteTimeIntervalPanel(NMONVisualizerGui gui) {
super(gui);
setLayout(new BorderLayout());
add.addActionListener(addInterval);
// start and end text boxes with labels, followed by a Add button
startLabel = new JLabel("Start:");
startLabel.setHorizontalAlignment(SwingConstants.TRAILING);
startLabel.setFont(Styles.LABEL);
start = new JSpinner(new SpinnerDateModel(new Date(getDefaultStartTime()), null, null, Calendar.MINUTE));
start.setEditor(new DateEditor(start, Styles.DATE_FORMAT_STRING_WITH_YEAR));
start.addChangeListener(intervalUpdater);
endLabel = new JLabel("End:");
endLabel.setHorizontalAlignment(SwingConstants.TRAILING);
endLabel.setFont(Styles.LABEL);
end = new JSpinner(new SpinnerDateModel(new Date(getDefaultEndTime()), null, null, Calendar.MINUTE));
end.setEditor(new DateEditor(end, Styles.DATE_FORMAT_STRING_WITH_YEAR));
end.addChangeListener(intervalUpdater);
JPanel namePanel = new JPanel();
namePanel.add(nameLabel);
namePanel.add(name);
JPanel startPanel = new JPanel();
startPanel.add(startLabel);
startPanel.add(start);
JPanel endPanel = new JPanel();
endPanel.add(endLabel);
endPanel.add(end);
JPanel buttonsPanel = new JPanel();
buttonsPanel.add(add);
buttonsPanel.add(endToStart);
buttonsPanel.add(reset);
JPanel dataPanel = new JPanel();
dataPanel.setLayout(new GridBagLayout());
GridBagConstraints labelConstraints = new GridBagConstraints();
GridBagConstraints fieldConstraints = new GridBagConstraints();
labelConstraints.gridx = 0;
fieldConstraints.gridx = 1;
labelConstraints.gridy = 0;
fieldConstraints.gridy = 0;
labelConstraints.insets = new Insets(0, 0, 0, 5);
fieldConstraints.insets = new Insets(5, 0, 0, 5);
labelConstraints.fill = GridBagConstraints.HORIZONTAL;
fieldConstraints.fill = GridBagConstraints.HORIZONTAL;
dataPanel.add(startLabel, labelConstraints);
dataPanel.add(start, fieldConstraints);
++labelConstraints.gridy;
++fieldConstraints.gridy;
dataPanel.add(endLabel, labelConstraints);
dataPanel.add(end, fieldConstraints);
add(namePanel, BorderLayout.PAGE_START);
add(dataPanel, BorderLayout.CENTER);
add(buttonsPanel, BorderLayout.PAGE_END);
}
项目:nmonvisualizer
文件:AbsoluteTimeIntervalPanel.java
@Override
TimeZone getTimeZone() {
DateEditor de = (DateEditor) start.getEditor();
return de.getFormat().getTimeZone();
}
项目:nmonvisualizer
文件:RelativeTimeIntervalPanel.java
@Override
TimeZone getTimeZone() {
DateEditor de = (DateEditor) base.getEditor();
return de.getFormat().getTimeZone();
}
项目:nmonvisualizer
文件:RelativeTimeIntervalPanel.java
@Override
public void propertyChange(PropertyChangeEvent evt) {
// all but timeZone fired by IntervalDocumentListeners
if ("interval".equals(evt.getPropertyName())) {
if (evt.getNewValue() == null) {
startLabel.setFont(Styles.LABEL_ERROR);
endLabel.setFont(Styles.LABEL_ERROR);
startLabel.setForeground(Styles.ERROR_COLOR);
endLabel.setForeground(Styles.ERROR_COLOR);
start.setForeground(Styles.ERROR_COLOR);
end.setForeground(Styles.ERROR_COLOR);
days.setForeground(Styles.ERROR_COLOR);
}
else {
startLabel.setFont(Styles.LABEL);
endLabel.setFont(Styles.LABEL);
startLabel.setForeground(Styles.DEFAULT_COLOR);
endLabel.setForeground(Styles.DEFAULT_COLOR);
start.setForeground(Styles.DEFAULT_COLOR);
end.setForeground(Styles.DEFAULT_COLOR);
days.setForeground(Styles.DEFAULT_COLOR);
}
}
else if ("start".equals(evt.getPropertyName())) {
startAbsolute.setText(FORMAT.format(new Date((Long) evt.getNewValue())));
}
else if ("end".equals(evt.getPropertyName())) {
endAbsolute.setText(FORMAT.format(new Date((Long) evt.getNewValue())));
}
else if ("timeZone".equals(evt.getPropertyName())) {
TimeZone timeZone = (TimeZone) evt.getNewValue();
DateEditor de = (DateEditor) base.getEditor();
de.getFormat().setTimeZone(timeZone);
// hack to get the spinner to fire a state change and update the displayed value
// toggle the calendar field back to its original value
((SpinnerDateModel) base.getModel()).setCalendarField(Calendar.MINUTE);
((SpinnerDateModel) base.getModel()).setCalendarField(Calendar.SECOND);
FORMAT.setTimeZone(timeZone);
startAbsolute.setText(FORMAT.format(new Date(getStartTime())));
endAbsolute.setText((FORMAT.format(new Date(getEndTime()))));
}
}
项目:nmonvisualizer
文件:BulkIntervalPanel.java
@Override
TimeZone getTimeZone() {
DateEditor de = (DateEditor) start.getEditor();
return de.getFormat().getTimeZone();
}