Solved

How to deploy the Toedter JCalendar

Posted on 2006-11-19
14
1,599 Views
Last Modified: 2007-12-19
Hi all,
stupid, but only after a long time I decided to deploy the JCalendar by Toedter to enter
dates or to confirm default dates.
However gorgeous the doc's and the demo are, I can't find out how to use it in my code.
I can't find a way to add an ActionListener or whatever.
Has anybody a simple coding example?

All I want for now is:
1) put the control in my frame,
2) preset a default date,
3) be alerted when a date is chosen,
4) get the new date to my program.

;JOOP!
0
Comment
Question by:sciuriware
  • 7
  • 5
  • 2
14 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17974258
Very strange - it seems to have been made unobservable. I'd be inclined to override

public void propertyChange(PropertyChangeEvent evt)

of JCalendar
0
 
LVL 10

Accepted Solution

by:
ADSLMark earned 500 total points
ID: 17974332
I didn't know of the existence but..

import java.util.*;
import javax.swing.*;
import java.beans.*;
import com.toedter.calendar.*;

class JDC extends JFrame implements PropertyChangeListener
{
    public JDC()
    {
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.setSize(800,600);

        JDateChooser dc = new JDateChooser(new Date());
        dc.addPropertyChangeListener(this);
        this.getContentPane().add(dc);
    }

    public void propertyChange(PropertyChangeEvent pce)
    {
        if(pce.getPropertyName().equals("date"))
            System.out.println(pce.getNewValue());
    }

    public static void main(String[] args)
    {
        JDC jdc = new JDC();
        jdc.setVisible(true);
    }
}

Looks like what you want?

Mark
0
 
LVL 10

Expert Comment

by:ADSLMark
ID: 17974343
I believe it is customary to have propertyChange overriden when using netbeans, no? Anyway, I made this example using the existing demo in the JCalendar package.. so it seems this is the way.

Mark
0
 
LVL 24

Author Comment

by:sciuriware
ID: 17974676
Not exactly but it is a start.

When I run with the provided source it crashes.
When I run with the provided .jar it works, but,
when I change JDateChooser to JCalendar it says it can't resolve JCalendar .....

;JOOP!
0
 
LVL 24

Author Comment

by:sciuriware
ID: 17974684
And it looks terrible anyway.

;JOOP!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17974686
>>when I change JDateChooser to JCalendar it says it can't resolve JCalendar .....

Can you post how you did that?
0
 
LVL 24

Author Comment

by:sciuriware
ID: 17974716
See the code above and
replace:

        JDateChooser dc = new JDateChooser(new Date());

by

        JCalendar dc = new JCalendar(new Date());

;JOOP!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Expert Comment

by:ADSLMark
ID: 17974723
"And it looks terrible anyway."

Haha, what did you expect? A fully working application which was precisely what you wanted? You wanted some example material.. and i gave precisely that what you requested. It's ok if you do not want to use it or think it's rubbish, it was just some quick code anyway.

Mark
0
 
LVL 24

Author Comment

by:sciuriware
ID: 17974725
ADSLMark, can you run your example yourself, it doesn't quite look like teodters pictures.

;JOOP!
0
 
LVL 10

Expert Comment

by:ADSLMark
ID: 17974761
Seems you do not understand the idea behind "a-push-in-the-right-direction".

Please do not comment on everything I say, just wait for someone else to give you a complete implementation with all the fuctionality you had in mind.
0
 
LVL 24

Author Comment

by:sciuriware
ID: 17974777
You are over-reacting.
The samples by Toedter show a single JCalendar component that you can click on.
I don't blame you for not knowing how to solve this.

It's just remarkable that this tool has been mentioned for years
but the deployment seems to be a riddle.

;JOOP!
0
 
LVL 10

Expert Comment

by:ADSLMark
ID: 17974856
Sorry, I really do not understand your problem. I downloaded the file at:

http://www.toedter.com/download/jcalendar-1.3.2.zip

and extract the content to disk. I went into the src directory and found in "com/toedter/calendar/demo" a very nice demo, showing the use of all the controls etc.
Just like the one demo on the website:

http://www.toedter.com/en/jcalendar/demo.html

So what is your problem really?
For the actionlistener, you have to use propertylistener and add that to the datechooser or whatever. Just add some System.out.println() to the propertyChanged() method and see what events are triggered when performing an action.

I do not understand why you can't get what you want. It really isn't that difficult. I thought I show you a very very simple example, which has only the essential code, without all layout issues etc. You thought it was rubbish, well fine, but the next possible example is already available to you..

If you want me to give you sth which looks more like you want, then give a better specification or post some sample code on how you want it to work and we can change your code in such way that it really works.

Good luck.
Mark
0
 
LVL 24

Author Comment

by:sciuriware
ID: 17974884
Rubbish is YOUR word, not mine.

In the demo you can click an icon which starts a JCalendar and which
puts the chosen date into a textfield.
The sources are such that I first asked if someone already had found out.
Digging in somebody elses sources is not my hobby.

All I was looking for was the control? that looks like a textfield and which launches the JCalendar.

Btw.: I got the JCalendar working now and I get 2 events for one date, which I get by .getDate();

;JOOP!
0
 
LVL 24

Author Comment

by:sciuriware
ID: 17986582
ADSLMark, I'm sorry I made a few stupid mistakes.
Your initial code works perfectly like the demo does.
The only thing I had to add was to set a date format beginning in a space and ending an extra space,
because setting the size to one that displayed the full date did not seem to work.

And please don't lose your temper when someone with 400000 points proves to be human too.

;JOOP!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HashMap Vs TreeMap 12 55
unix in java example 9 53
advertisement module in core php 4 144
servlet filter example 37 42
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now