Jcalendar 简单使用

今天想找一个像js那样能在swing中使用的日历控件。找到jcalendar后,本想搜一下用法,哪知道google上全是提的问题,一下把我打蒙了,最后在才发现可能是太过于简单都没人回复了,本人弄了一个小例子。

 

 

package com.daniel.test; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import com.toedter.calendar.JDateChooser; public class TestCalender extends JFrame{ private JDateChooser jDateChooser; private JButton jButton; public TestCalender(){ setTitle("Test Calender"); setLayout(new FlowLayout()); setSize(new Dimension(200,150)); jDateChooser = new JDateChooser(); jButton = new JButton("提交表单"); add(jDateChooser); add(jButton); jButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub JOptionPane.showConfirmDialog(null, "你选择的日期是:" + jDateChooser.getDate().toLocaleString()); } }); } public static void main(String args[]){ TestCalender test = new TestCalender(); test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); test.setVisible(true); } }

你可能感兴趣的:(swing,String,Google,null,Class,日历)