How should I install JDateChooser?

iamanapprentice picture iamanapprentice · Jun 9, 2011 · Viewed 40.9k times · Source

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

Answer

Costis Aivalis picture Costis Aivalis · Jun 9, 2011

It's very simple.

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

enter image description here

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

enter image description here

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));