Start New Discussion within our Software Development Community

Hey everybody :)

So im new to programming and im using the jDateChooser from the com.toedter.calendar package

the problem that I am having is that I am not able to get the current date to display ... you have to just select the date yourself ... can anyone give me some help with this

also how do you set another jDateChooser 1 month after the current day?

Many thanks in advance for any help that comes my way :)

Greg Stoltz

Hello Greg try get/set methods:

//package com.toedter.calendar.JCalendar;
 public static void main(String[] s) {
        JFrame frame = new JFrame("JCalendar");
        JCalendar jcalendar = new JCalendar();
        frame.getContentPane().add(jcalendar);
        frame.pack();
        frame.setVisible(true);
        //1.
        Date date = jcalendar.getDate();
        System.out.println(date);
        //2.
        //second calendar

        JFrame frame2 = new JFrame("JCalendar2");
        JCalendar jcalendar2 = new JCalendar();
        frame2.getContentPane().add(jcalendar2);
        frame2.pack();
        frame2.setVisible(true);
        int month = jcalendar2.getMonthChooser().getMonth();
        System.out.println(month);
        // months calculated from zero
        month++;
        // attention also check month [0,11], no more then 11, change year
        jcalendar2.getMonthChooser().setMonth(month);
        Date date2 = jcalendar2.getDate();
        System.out.println(date2);
    }

Result

run:
Fri Jul 24 01:07:24 CEST 2009
6
Mon Aug 24 01:07:24 CEST 2009

quuba

This article has been dead for over six months. Start a new discussion instead.