开发者

How should I install JDateChooser?

开发者 https://www.devze.com 2023-03-11 07:25 出处:网络
I\'ve discover this JDateChooser from searching how to use Item Combobox at Java Swing.Do you know how 开发者_开发知识库to install this?

I've discover this JDateChooser from searching how to use Item Combobox at Java Swing. Do you know how 开发者_开发知识库to install this?

Here is the link JDateChooser

I can't find any instructions on how to install it..

Can you share some instructions on how to install it... thanks in advance v(^_^)v


It's very simple.

Download the Toedter jcalendar-1.4.jar (also maven repository will locate it) If you are using Netbeans you can create an new bean and add the Toedter beans to your Palette Manager:

How should I install JDateChooser?

This gives you the capability to drag and drop these anywhere you like:

How should I install JDateChooser?

If you drag and drop the bean somewhere, the code that is generated looks like here:

jDateChooser1 = new com.toedter.calendar.JDateChooser();
jDateChooser1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jDateChooser1.setDateFormatString("dd/MM/yyyy");

You can then use the beans like this:

 java.sql.Date di = rs.getDate("edate");
 jDateChooser1.setDate(di);

or

java.util.Date jud =  jDateChooser1.getDate();
long t = jud.getTime();
java.sql.Date sqd = new java.sql.Date(t);
rs.updateDate("edate", sqd);

or like this if you want to format the Date:

java.util.Date jud =  jDateChooser1.getDate();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM dd, yyyy");
jLabel1.setText(sdf.format(jud));


Add the sources to yours and use the classes like in JCalendarDemo.java

0

精彩评论

暂无评论...
验证码 换一张
取 消