使用Swing的JSpinner組件設置日期時間選擇器


代碼:

 1 //獲得時間日期模型
 2         SpinnerDateModel model = new SpinnerDateModel();
 3         //獲得JSPinner對象
 4         JSpinner year = new JSpinner(model);
 5         year.setValue(new Date());
 6         //設置時間格式
 7         JSpinner.DateEditor editor = new JSpinner.DateEditor(year,
 8                 "yyyy-MM-dd HH:mm:ss");
 9         year.setEditor(editor);
10         year.setBounds(34, 67, 219, 22);
11         contentPane.add(year);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM