hysun.util
Class DateChooser

java.lang.Object
  - java.awt.Component
      - java.awt.Container
          - java.awt.Window
              - java.awt.Dialog
                  - javax.swing.JDialog
                      - hysun.util.DateChooser

public class DateChooser
extends javax.swing.JDialog

A simple and easy to use Date Chooser, based on the MonthlyCalendar component.

Usage:

    DateChooser dc = new DateChooser(parentFrame, true/false);
    ...
    dc.setVisible(true); //this will initialise the calendar to current date
    Calendar cal = dc.getSelectedDate();  //get selected date
    if (cal == null) {
        //means no date selected (i.e. dialog closed by Close button)
    } else {
        //do whatever u want with the selected date.
    }
 

Constructor Detail (Similar set of constructors as JDialog)

DateChooser

public DateChooser()

DateChooser

public DateChooser(java.awt.Dialog owner)

DateChooser

public DateChooser(java.awt.Dialog owner,
                   boolean modal)

DateChooser

public DateChooser(java.awt.Dialog owner,
                   java.lang.String title)

DateChooser

public DateChooser(java.awt.Dialog owner,
                   java.lang.String title,
                   boolean modal)

DateChooser

public DateChooser(java.awt.Dialog owner,
                   java.lang.String title,
                   boolean modal,
                   java.awt.GraphicsConfiguration gc)

DateChooser

public DateChooser(java.awt.Frame owner)

DateChooser

public DateChooser(java.awt.Frame owner,
                   boolean modal)

DateChooser

public DateChooser(java.awt.Frame owner,
                   java.lang.String title)

DateChooser

public DateChooser(java.awt.Frame owner,
                   java.lang.String title,
                   boolean modal)

DateChooser

public DateChooser(java.awt.Frame owner,
                   java.lang.String title,
                   boolean modal,
                   java.awt.GraphicsConfiguration gc)
Method Detail

setVisible

public void setVisible(boolean b)
Override parent setVisible method to include resetting of highlighted date
Overrides:
setVisible in class java.awt.Component

getSelectedDate

public java.util.Calendar getSelectedDate()
User code can call this method to get the selected date as a Calendar object. If the DateChooser dialog is closed by clicking the "Close" button, this method returns null; Else, the DateChooser dialog is closed by selecting a date, and the method will return a Calendar object representing that date.

setYearMonth

public void setYearMonth(int y,
                         int m)
Set the calendar year and month to the specified value. Should be called before set the date chooser visible.

setWeekStartOnSunday

public void setWeekStartOnSunday(boolean b)
Bean method to set start day of a week. Will delegate to MonthlyCalendar.setWeekStartOnSunday(boolean) method.

getWeekStartOnSunday

public boolean getWeekStartOnSunday()
Bean method to get start day of a week. Will delegate to MonthlyCalendar.getWeekStartOnSunday method.