| Author |
JCalendar Date Picker question
|
Rus Corina
Ranch Hand
Joined: Jul 08, 2011
Posts: 90
|
|
|
Hello. I need to use a datePicker, and I found the one made by TOEDTER ( http://www.toedter.com/en/jcalendar/ ). It seems pretty good, and mainly just what I need, but I don't know how to use it. I developed my project in Netbeans, but the problem is that I create all my components manually (ex: JTextField f= new JTextField()), and place them on the screen and assign actions by writing code, and the tutorials that I found that teach you how to use JCalendar involve adding the JCalendar to the palette and put it on your frame through drag and drop. Having the project (it has a jar file where all the JCalendar classes are included), how can I include it in my own application? I don't know, maybe it can be included with something similar to "import javax.swing.*;" ?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
After you've added the JAR file to your project's class path, that's indeed all you need to do - import the right class(es). You would need to import at least com.toedter.calendar.JCalendar; you can then use any of JCalendar's constructors to create your instance.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Rus Corina
Ranch Hand
Joined: Jul 08, 2011
Posts: 90
|
|
|
Thank you very much, I finally managed to do that myself. Now I have another problem: can the way in which the date is displayed in the text field be changed?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
If you're using a JDateChooser instead of a JCalendar, then I think that you can use setDateFormatString for that.
|
 |
Rus Corina
Ranch Hand
Joined: Jul 08, 2011
Posts: 90
|
|
Well, i tried this, and it works except for the month. It just writes dd.33.yyyy, regardless of what month i choose.
The code i wrote is like this:
datt.setDateFormatString("DD.MM.YYYY");
Any idea why it does not work for month?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You need to use "dd.MM.yyyy". The case is very important; lowercase "mm" means minute. That works for me.
|
 |
Rus Corina
Ranch Hand
Joined: Jul 08, 2011
Posts: 90
|
|
It worked for me too. Thanks
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You're welcome.
|
 |
 |
|
|
subject: JCalendar Date Picker question
|
|
|