當前位置: 首頁>>代碼示例>>Java>>正文


Java SpinnerDateModel類代碼示例

本文整理匯總了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;
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:20,代碼來源:DateTimePicker.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:13,代碼來源:JSpinnerJavaElementTest.java

示例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()); 
	
}
 
開發者ID:fossasia,項目名稱:zooracle,代碼行數:13,代碼來源:ComparePanel.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:bug8008657.java

示例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;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:25,代碼來源:SpinnerDemo.java

示例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);
}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:18,代碼來源:SpinnerDemo.java

示例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);
}
 
開發者ID:iig-uni-freiburg,項目名稱:SWAT20,代碼行數:26,代碼來源:TimeFilterDialog.java

示例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;
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:25,代碼來源:SpinnerDemo.java

示例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");
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:30,代碼來源:JXDatePickerIssues.java

示例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);
}
 
開發者ID:msanpopo,項目名稱:kgsview,代碼行數:25,代碼來源:DateFilterPanel.java

示例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;
}
 
開發者ID:dogriffiths,項目名稱:hipster,代碼行數:19,代碼來源:XMLPanel.java

示例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);		
}
 
開發者ID:Distrotech,項目名稱:jhylafax,代碼行數:23,代碼來源:AbstractFaxDialog.java

示例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());
}
 
開發者ID:RandomWidgets,項目名稱:TechScore,代碼行數:20,代碼來源:RPDatabasePane.java

示例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);
}
 
開發者ID:52North,項目名稱:sos-importer,代碼行數:17,代碼來源:MissingDatePanel.java

示例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);
}
 
開發者ID:52North,項目名稱:sos-importer,代碼行數:17,代碼來源:MissingTimePanel.java


注:本文中的javax.swing.SpinnerDateModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。