aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to get date from JDateChooser into the textfield Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to get date from JDateChooser into the textfield" Watch "How to get date from JDateChooser into the textfield" New topic
Author

How to get date from JDateChooser into the textfield

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Hello
I have to use some sort of date picker just after the date textfield.
I have downloaded JCalender1.4 zip from webpage. But i don't know how to use it. I have looked into its api. i have added the JAR file to project's class path(i am using myeclipse8.5).

I have created a JDateChoose constructor and related it with a text field. It now displays the calender, but doesn't displays the date in the textfield. I think there would be some listener to do this. I guess ActionListener. But i don't know how to proceed

Here is what i did



Thanks


kunal
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

I looked at that page you linked to, and I noticed a mention of demo code. I suggest you look at that demo code, find something which does what you want to do, and use the code from that demo.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Thanks for your reply Paul Clapham
I had an eye upon the code, but, didn't got any help
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Still no success
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8



Did you get this line of code from one of the demo programs?
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
No.

I wrote it. i saw that JDateChooser has an add method which take component as an argument. I tried it. But, i am not sure whether its right or wrong
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

I don't know about "right" and "wrong" but your test clearly shows that it doesn't do what you expected it to do. Again I suggest that you look at the demo code which you have readily available.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Okay. I am having a look on it.

(I guess you are talking about JCalenderDemo.java)
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Still unsuccessful

Actually, i didn't spent much time on it, as i am late to meet the deadline of my project.

See, if you can provide some close hints.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Didn't got any help from demo code. Actually, didn't understood many things.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

I haven't looked at the documentation, but I would expect the JDateChooser to have a method named getDate() -- or something very much like that -- which returns the Date which the user chose. That's what you should be using.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Thanks Paul Clapham

That was quite simple. It was so stupid of me.

Once again, thanks a lot.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to get date from JDateChooser into the textfield