aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JCalendar Date Picker question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JCalendar Date Picker question" Watch "JCalendar Date Picker question" New topic
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: 19792
    
  20

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 - OCEEJBD 6
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: 19792
    
  20

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: 19792
    
  20

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: 19792
    
  20

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JCalendar Date Picker question