本文整理匯總了Java中javax.swing.SpinnerDateModel類的典型用法代碼示例。如果您正苦於以下問題:Java SpinnerDateModel類的具體用法?Java SpinnerDateModel怎麽用?Java SpinnerDateModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SpinnerDateModel類屬於javax.swing包,在下文中一共展示了SpinnerDateModel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTimePanel
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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;
}
示例2: createDateSpinner
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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;
}
示例3: ComparePanel
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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());
}
示例4: createDateSpinner
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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);
}
示例5: createPanel2
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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;
}
示例6: main
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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);
}
示例7: DatePickerPanel
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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);
}
示例8: createPanel2
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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;
}
示例9: interactiveDatePickerNimbus
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
/**
* 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");
}
示例10: DateFilterPanel
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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);
}
示例11: makeDate
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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;
}
示例12: addDateControls
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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);
}
示例13: DatabaseRow
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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());
}
示例14: MissingDatePanel
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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);
}
示例15: MissingTimePanel
import javax.swing.SpinnerDateModel; //導入依賴的package包/類
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);
}