Solved

How to deploy the Toedter JCalendar

Posted on 2006-11-19
14
1,607 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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
 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Options in Zimbra Server 2 53
servlet example issue 6 39
Configure a Bean in an XML file 4 31
JAVA API design with micro service cloud in mind 1 16
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

773 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