Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I install JDateChooser?

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

like image 892
iamanapprentice Avatar asked Dec 05 '22 21:12

iamanapprentice


2 Answers

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:

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));
like image 76
Costis Aivalis Avatar answered Dec 23 '22 23:12

Costis Aivalis


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

like image 28
oliholz Avatar answered Dec 24 '22 01:12

oliholz