From 6deeb57d62c238d3f152cdef1d782b441c73797a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 4 Mar 2009 18:25:32 +0000 Subject: jcalendar lib --- CHANGELOG.txt | 1 + build.xml | 6 + libs/FLib/JCalendar/doc/example/Example1.java | 196 +- libs/FLib/JCalendar/doc/example/Example2.java | 182 +- .../JCalendar/org/freixas/jcalendar/DateEvent.java | 76 +- .../org/freixas/jcalendar/DateListener.java | 18 +- .../JCalendar/org/freixas/jcalendar/JCalendar.java | 2675 ++++++++--------- .../org/freixas/jcalendar/JCalendarCombo.java | 2010 ++++++------- libs/FLib/JWizard/doc/example/Example1.java | 945 +++--- .../JWizard/org/freixas/jwizard/JWizardDialog.java | 1536 +++++----- .../JWizard/org/freixas/jwizard/JWizardPanel.java | 622 ++-- libs/FLib/TableLayout/doc/example/Example1.java | 242 +- .../TableLayout/doc/example/TableExplorer.java | 2118 ++++++------- .../org/freixas/tablelayout/TableLayout.java | 3114 ++++++++++---------- sources/client/NetCalendarClient.java | 11 + 15 files changed, 6888 insertions(+), 6864 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ea00c53..bd6b8ec 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,6 @@ Changes from 1.0 -> 1.1 SVN +* Added JCalendar library for nice Calendar displaying * Addaed the current time to the bottom right of the GUI * Added a few key shortcuts * conf.txt has been renamed into netcalendar.conf diff --git a/build.xml b/build.xml index 9baf726..7f8ddc4 100644 --- a/build.xml +++ b/build.xml @@ -6,6 +6,7 @@ + @@ -14,6 +15,10 @@ + + + + @@ -23,6 +28,7 @@ + diff --git a/libs/FLib/JCalendar/doc/example/Example1.java b/libs/FLib/JCalendar/doc/example/Example1.java index 57e3b87..c64e64c 100644 --- a/libs/FLib/JCalendar/doc/example/Example1.java +++ b/libs/FLib/JCalendar/doc/example/Example1.java @@ -33,146 +33,146 @@ import org.freixas.jcalendar.*; // All Rights Reserved. public class Example1 - extends JFrame + extends JFrame { //********************************************************************** // main //********************************************************************** -public static void -main( - String[] args) -{ - new Example1(); -} + public static void + main( + String[] args) + { + new Example1(); + } //********************************************************************** // Constructors //********************************************************************** -/** - * Create various instances of a JCalendar. - */ + /** + * Create various instances of a JCalendar. + */ -public -Example1() -{ - // Set up the frame + public + Example1() + { + // Set up the frame - setTitle("Example1"); - setDefaultCloseOperation(EXIT_ON_CLOSE); + setTitle("Example1"); + setDefaultCloseOperation(EXIT_ON_CLOSE); - Container contentPane = getContentPane(); - contentPane.setLayout(new GridLayout(2, 2, 5, 5)); + Container contentPane = getContentPane(); + contentPane.setLayout(new GridLayout(2, 2, 5, 5)); - // Create a border for all calendars + // Create a border for all calendars - Border etchedBorder = - BorderFactory.createEtchedBorder(); - Border emptyBorder = - BorderFactory.createEmptyBorder(10, 10, 10, 10); - Border compoundBorder = - BorderFactory.createCompoundBorder(etchedBorder, emptyBorder); + Border etchedBorder = + BorderFactory.createEtchedBorder(); + Border emptyBorder = + BorderFactory.createEmptyBorder(10, 10, 10, 10); + Border compoundBorder = + BorderFactory.createCompoundBorder(etchedBorder, emptyBorder); - // Create a date listener to be used for all calendars + // Create a date listener to be used for all calendars - MyDateListener listener = new MyDateListener(); + MyDateListener listener = new MyDateListener(); - // Display date and time using the default calendar and locale. - // Display today's date at the bottom. + // Display date and time using the default calendar and locale. + // Display today's date at the bottom. - JCalendar calendar1 = - new JCalendar( - JCalendar.DISPLAY_DATE | JCalendar.DISPLAY_TIME, - true); - calendar1.addDateListener(listener); - calendar1.setBorder(compoundBorder); + JCalendar calendar1 = + new JCalendar( + JCalendar.DISPLAY_DATE | JCalendar.DISPLAY_TIME, + true); + calendar1.addDateListener(listener); + calendar1.setBorder(compoundBorder); - // Set fonts rather than using defaults + // Set fonts rather than using defaults - calendar1.setTitleFont(new Font("Serif", Font.BOLD|Font.ITALIC, 24)); - calendar1.setDayOfWeekFont(new Font("SansSerif", Font.ITALIC, 12)); - calendar1.setDayFont(new Font("SansSerif", Font.BOLD, 16)); - calendar1.setTimeFont(new Font("DialogInput", Font.PLAIN, 10)); - calendar1.setTodayFont(new Font("Dialog", Font.PLAIN, 14)); + calendar1.setTitleFont(new Font("Serif", Font.BOLD|Font.ITALIC, 24)); + calendar1.setDayOfWeekFont(new Font("SansSerif", Font.ITALIC, 12)); + calendar1.setDayFont(new Font("SansSerif", Font.BOLD, 16)); + calendar1.setTimeFont(new Font("DialogInput", Font.PLAIN, 10)); + calendar1.setTodayFont(new Font("Dialog", Font.PLAIN, 14)); - // Display date only + // Display date only - JCalendar calendar2 = new JCalendar(JCalendar.DISPLAY_DATE, false); - calendar2.addDateListener(listener); - calendar2.setBorder(compoundBorder); + JCalendar calendar2 = new JCalendar(JCalendar.DISPLAY_DATE, false); + calendar2.addDateListener(listener); + calendar2.setBorder(compoundBorder); - // Display time only and set the time pattern to use as a duration - // from 00:00 to 23:59 + // Display time only and set the time pattern to use as a duration + // from 00:00 to 23:59 - JCalendar calendar3 = - new JCalendar( - Calendar.getInstance(), - Locale.getDefault(), - JCalendar.DISPLAY_TIME, - false, - "HH:mm"); - calendar3.addDateListener(listener); - calendar3.setBorder(compoundBorder); + JCalendar calendar3 = + new JCalendar( + Calendar.getInstance(), + Locale.getDefault(), + JCalendar.DISPLAY_TIME, + false, + "HH:mm"); + calendar3.addDateListener(listener); + calendar3.setBorder(compoundBorder); - // Display a French calendar + // Display a French calendar - JCalendar calendar4 = - new JCalendar( - Calendar.getInstance(Locale.FRENCH), - Locale.FRENCH, - JCalendar.DISPLAY_DATE | JCalendar.DISPLAY_TIME, - false); - calendar4.addDateListener(listener); - calendar4.setBorder(compoundBorder); + JCalendar calendar4 = + new JCalendar( + Calendar.getInstance(Locale.FRENCH), + Locale.FRENCH, + JCalendar.DISPLAY_DATE | JCalendar.DISPLAY_TIME, + false); + calendar4.addDateListener(listener); + calendar4.setBorder(compoundBorder); - // Add all the calendars to the content pane + // Add all the calendars to the content pane - JPanel panel1 = new JPanel(new FlowLayout()); - panel1.add(calendar1); - contentPane.add(panel1); + JPanel panel1 = new JPanel(new FlowLayout()); + panel1.add(calendar1); + contentPane.add(panel1); - JPanel panel2 = new JPanel(new FlowLayout()); - panel2.add(calendar2); - contentPane.add(panel2); + JPanel panel2 = new JPanel(new FlowLayout()); + panel2.add(calendar2); + contentPane.add(panel2); - JPanel panel3 = new JPanel(new FlowLayout()); - panel3.add(calendar3); - contentPane.add(panel3); + JPanel panel3 = new JPanel(new FlowLayout()); + panel3.add(calendar3); + contentPane.add(panel3); - JPanel panel4 = new JPanel(new FlowLayout()); - panel4.add(calendar4); - contentPane.add(panel4); + JPanel panel4 = new JPanel(new FlowLayout()); + panel4.add(calendar4); + contentPane.add(panel4); - // Make the window visible + // Make the window visible - pack(); - setVisible(true); -} + pack(); + setVisible(true); + } //********************************************************************** // Inner Classes //********************************************************************** -private class MyDateListener - implements DateListener -{ + private class MyDateListener + implements DateListener + { + + public void + dateChanged( + DateEvent e) + { + Calendar c = e.getSelectedDate(); + if (c != null) { + System.out.println(c.getTime()); + } + else { + System.out.println("No time selected."); + } + } -public void -dateChanged( - DateEvent e) -{ - Calendar c = e.getSelectedDate(); - if (c != null) { - System.out.println(c.getTime()); - } - else { - System.out.println("No time selected."); } -} - -} //********************************************************************** // End Inner Classes diff --git a/libs/FLib/JCalendar/doc/example/Example2.java b/libs/FLib/JCalendar/doc/example/Example2.java index 0866447..0299ef9 100644 --- a/libs/FLib/JCalendar/doc/example/Example2.java +++ b/libs/FLib/JCalendar/doc/example/Example2.java @@ -33,138 +33,138 @@ import org.freixas.jcalendar.*; // All Rights Reserved. class Example2 - extends JFrame + extends JFrame { //********************************************************************** // main //********************************************************************** -public static void -main( - String[] args) -{ - new Example2(); -} + public static void + main( + String[] args) + { + new Example2(); + } //********************************************************************** // Constructors //********************************************************************** -/** - * Create various instances of a JCalendarCombo. - */ + /** + * Create various instances of a JCalendarCombo. + */ -public -Example2() -{ - // Set up the frame + public + Example2() + { + // Set up the frame - setTitle("Example2"); - setDefaultCloseOperation(EXIT_ON_CLOSE); + setTitle("Example2"); + setDefaultCloseOperation(EXIT_ON_CLOSE); - Container contentPane = getContentPane(); - contentPane.setLayout(new GridLayout(2, 2, 5, 5)); + Container contentPane = getContentPane(); + contentPane.setLayout(new GridLayout(2, 2, 5, 5)); - // Create a date listener to be used for all calendars + // Create a date listener to be used for all calendars - MyDateListener listener = new MyDateListener(); + MyDateListener listener = new MyDateListener(); - // Display date and time using the default calendar and locale. - // Display today's date at the bottom. Allow editing + // Display date and time using the default calendar and locale. + // Display today's date at the bottom. Allow editing - JCalendarCombo calendar1 = - new JCalendarCombo( - JCalendarCombo.DISPLAY_DATE | JCalendarCombo.DISPLAY_TIME, - true); - calendar1.setEditable(true); - calendar1.addDateListener(listener); + JCalendarCombo calendar1 = + new JCalendarCombo( + JCalendarCombo.DISPLAY_DATE | JCalendarCombo.DISPLAY_TIME, + true); + calendar1.setEditable(true); + calendar1.addDateListener(listener); - // Set fonts rather than using defaults + // Set fonts rather than using defaults - calendar1.setFont(new Font("DialogInput", Font.PLAIN, 16)); + calendar1.setFont(new Font("DialogInput", Font.PLAIN, 16)); - calendar1.setTitleFont(new Font("Serif", Font.BOLD|Font.ITALIC, 24)); - calendar1.setDayOfWeekFont(new Font("SansSerif", Font.ITALIC, 12)); - calendar1.setDayFont(new Font("SansSerif", Font.BOLD, 16)); - calendar1.setTimeFont(new Font("DialogInput", Font.PLAIN, 10)); - calendar1.setTodayFont(new Font("Dialog", Font.PLAIN, 14)); + calendar1.setTitleFont(new Font("Serif", Font.BOLD|Font.ITALIC, 24)); + calendar1.setDayOfWeekFont(new Font("SansSerif", Font.ITALIC, 12)); + calendar1.setDayFont(new Font("SansSerif", Font.BOLD, 16)); + calendar1.setTimeFont(new Font("DialogInput", Font.PLAIN, 10)); + calendar1.setTodayFont(new Font("Dialog", Font.PLAIN, 14)); - // Display date only + // Display date only - JCalendarCombo calendar2 = - new JCalendarCombo(JCalendarCombo.DISPLAY_DATE, false); - calendar2.addDateListener(listener); + JCalendarCombo calendar2 = + new JCalendarCombo(JCalendarCombo.DISPLAY_DATE, false); + calendar2.addDateListener(listener); - // Display time only and set the time pattern to use as a duration - // from 00:00 to 23:59 + // Display time only and set the time pattern to use as a duration + // from 00:00 to 23:59 - JCalendarCombo calendar3 = - new JCalendarCombo( - Calendar.getInstance(), - Locale.getDefault(), - JCalendarCombo.DISPLAY_TIME, - false, - "HH:mm:ss"); - calendar3.setDateFormat(new SimpleDateFormat("HH:mm:ss")); - calendar3.addDateListener(listener); + JCalendarCombo calendar3 = + new JCalendarCombo( + Calendar.getInstance(), + Locale.getDefault(), + JCalendarCombo.DISPLAY_TIME, + false, + "HH:mm:ss"); + calendar3.setDateFormat(new SimpleDateFormat("HH:mm:ss")); + calendar3.addDateListener(listener); - // Display a French calendar + // Display a French calendar - JCalendarCombo calendar4 = - new JCalendarCombo( - Calendar.getInstance(Locale.FRENCH), - Locale.FRENCH, - JCalendarCombo.DISPLAY_DATE | JCalendarCombo.DISPLAY_TIME, - false); - calendar4.addDateListener(listener); + JCalendarCombo calendar4 = + new JCalendarCombo( + Calendar.getInstance(Locale.FRENCH), + Locale.FRENCH, + JCalendarCombo.DISPLAY_DATE | JCalendarCombo.DISPLAY_TIME, + false); + calendar4.addDateListener(listener); - // Add all the calendars to the content pane + // Add all the calendars to the content pane - JPanel panel1 = new JPanel(new BorderLayout()); - panel1.add(calendar1, BorderLayout.NORTH); - contentPane.add(panel1); + JPanel panel1 = new JPanel(new BorderLayout()); + panel1.add(calendar1, BorderLayout.NORTH); + contentPane.add(panel1); - JPanel panel2 = new JPanel(new BorderLayout()); - panel2.add(calendar2, BorderLayout.NORTH); - contentPane.add(panel2); + JPanel panel2 = new JPanel(new BorderLayout()); + panel2.add(calendar2, BorderLayout.NORTH); + contentPane.add(panel2); - JPanel panel3 = new JPanel(new BorderLayout()); - panel3.add(calendar3, BorderLayout.NORTH); - contentPane.add(panel3); + JPanel panel3 = new JPanel(new BorderLayout()); + panel3.add(calendar3, BorderLayout.NORTH); + contentPane.add(panel3); - JPanel panel4 = new JPanel(new BorderLayout()); - panel4.add(calendar4, BorderLayout.NORTH); - contentPane.add(panel4); + JPanel panel4 = new JPanel(new BorderLayout()); + panel4.add(calendar4, BorderLayout.NORTH); + contentPane.add(panel4); - // Make the window visible + // Make the window visible - pack(); - setVisible(true); -} + pack(); + setVisible(true); + } //********************************************************************** // Inner Classes //********************************************************************** -private class MyDateListener - implements DateListener -{ + private class MyDateListener + implements DateListener + { + + public void + dateChanged( + DateEvent e) + { + Calendar c = e.getSelectedDate(); + if (c != null) { + System.out.println(c.getTime()); + } + else { + System.out.println("No time selected."); + } + } -public void -dateChanged( - DateEvent e) -{ - Calendar c = e.getSelectedDate(); - if (c != null) { - System.out.println(c.getTime()); - } - else { - System.out.println("No time selected."); } -} - -} //********************************************************************** // End Inner Classes diff --git a/libs/FLib/JCalendar/org/freixas/jcalendar/DateEvent.java b/libs/FLib/JCalendar/org/freixas/jcalendar/DateEvent.java index dfd4f9f..9058dc4 100644 --- a/libs/FLib/JCalendar/org/freixas/jcalendar/DateEvent.java +++ b/libs/FLib/JCalendar/org/freixas/jcalendar/DateEvent.java @@ -24,63 +24,63 @@ import java.util.Calendar; // All Rights Reserved. public class DateEvent - extends EventObject + extends EventObject { //********************************************************************** // Private Members //********************************************************************** -private Calendar selectedDate; + private Calendar selectedDate; //********************************************************************** // Constructors //********************************************************************** -/** - * Create a date event. - * - * @param source The object on which the event occurred. - * @param selectedDate The selected date. - */ - -public -DateEvent( - Object source, - Calendar selectedDate) -{ - super(source); - this.selectedDate = selectedDate; -} + /** + * Create a date event. + * + * @param source The object on which the event occurred. + * @param selectedDate The selected date. + */ + + public + DateEvent( + Object source, + Calendar selectedDate) + { + super(source); + this.selectedDate = selectedDate; + } //********************************************************************** // Public //********************************************************************** -/** - * Return the selected date. - * - * @return The selected date. - */ + /** + * Return the selected date. + * + * @return The selected date. + */ -public Calendar -getSelectedDate() -{ - return selectedDate; -} + public Calendar + getSelectedDate() + { + return selectedDate; + } //The default equals and hashCode methods are acceptable. -/** - * {@inheritDoc} - */ - -public String -toString() -{ - return - super.toString() + ",selectedDate=" + - selectedDate.getTime().toString(); -} + /** + * {@inheritDoc} + */ + + public String + toString() + { + return + super.toString() + ",selectedDate=" + + selectedDate.getTime().toString(); + } } diff --git a/libs/FLib/JCalendar/org/freixas/jcalendar/DateListener.java b/libs/FLib/JCalendar/org/freixas/jcalendar/DateListener.java index 7d3f723..3d29476 100644 --- a/libs/FLib/JCalendar/org/freixas/jcalendar/DateListener.java +++ b/libs/FLib/JCalendar/org/freixas/jcalendar/DateListener.java @@ -22,7 +22,7 @@ import java.util.EventListener; // All Rights Reserved. public interface DateListener - extends EventListener + extends EventListener { //********************************************************************** @@ -33,14 +33,14 @@ public interface DateListener // Public //********************************************************************** -/** - * This method is called each time a date in a calendar changes. - * - * @param e The date event information. - */ + /** + * This method is called each time a date in a calendar changes. + * + * @param e The date event information. + */ -public void -dateChanged( - DateEvent e); + public void + dateChanged( + DateEvent e); } diff --git a/libs/FLib/JCalendar/org/freixas/jcalendar/JCalendar.java b/libs/FLib/JCalendar/org/freixas/jcalendar/JCalendar.java index 5e305f1..7843669 100644 --- a/libs/FLib/JCalendar/org/freixas/jcalendar/JCalendar.java +++ b/libs/FLib/JCalendar/org/freixas/jcalendar/JCalendar.java @@ -95,33 +95,33 @@ import java.util.ResourceBundle; // All Rights Reserved. public class JCalendar - extends JPanel + extends JPanel { //********************************************************************** // Public Constants //********************************************************************** -/** - * Used to indicate that this component should display the date. - */ + /** + * Used to indicate that this component should display the date. + */ -public static final int DISPLAY_DATE = 0x01; + public static final int DISPLAY_DATE = 0x01; -/** - * Used to indicate that this component should display the time. - */ + /** + * Used to indicate that this component should display the time. + */ -public static final int DISPLAY_TIME = 0x02; + public static final int DISPLAY_TIME = 0x02; //********************************************************************** // Private Constants //********************************************************************** -private static final int MONTH_DECR_BUTTON = 0; -private static final int MONTH_INCR_BUTTON = 1; -private static final int YEAR_DECR_BUTTON = 2; -private static final int YEAR_INCR_BUTTON = 3; + private static final int MONTH_DECR_BUTTON = 0; + private static final int MONTH_INCR_BUTTON = 1; + private static final int YEAR_DECR_BUTTON = 2; + private static final int YEAR_INCR_BUTTON = 3; //********************************************************************** // Private Members @@ -130,1364 +130,1365 @@ private static final int YEAR_INCR_BUTTON = 3; // This determines the components being displayed: the calendar, the // time spinner, or both -private int selectedComponents; + private int selectedComponents; // The calendar containing a selected day. The selected day may not be // always be displayed -private Calendar selectedCalendar; -private int selectedYear = -1; -private int selectedMonth = -1; -private int selectedDay = -1; -private int selectedHour = -1; -private int selectedMinute = -1; -private int selectedSecond = -1; + private Calendar selectedCalendar; + private int selectedYear = -1; + private int selectedMonth = -1; + private int selectedDay = -1; + private int selectedHour = -1; + private int selectedMinute = -1; + private int selectedSecond = -1; // The calendar we display -private Calendar displayCalendar; -private int displayYear; -private int displayMonth; + private Calendar displayCalendar; + private int displayYear; + private int displayMonth; // The locale to use -private Locale locale; + private Locale locale; // True if we display today's date -private boolean isTodayDisplayed = false; + private boolean isTodayDisplayed = false; // A null date is equivalent to having no date selected. Note that the // constructor selects the current date (today) -private boolean isNullAllowed = true; -private boolean isNullDate = true; + private boolean isNullAllowed = true; + private boolean isNullDate = true; // The time pattern used to set the format of the time spinner -private String timePattern; + private String timePattern; // Components -private JButton yearDecrButton; -private JButton monthDecrButton; -private JLabel monthYearLabel; -private JButton monthIncrButton; -private JButton yearIncrButton; + private JButton yearDecrButton; + private JButton monthDecrButton; + private JLabel monthYearLabel; + private JButton monthIncrButton; + private JButton yearIncrButton; -private JLabel[] dayOfWeekLabels; -private JToggleButton[][] dayButtons; -private JToggleButton offScreenButton; -private ButtonGroup dayGroup; + private JLabel[] dayOfWeekLabels; + private JToggleButton[][] dayButtons; + private JToggleButton offScreenButton; + private ButtonGroup dayGroup; -private SpinnerDateModel spinnerDateModel; -private JSpinner spinner; + private SpinnerDateModel spinnerDateModel; + private JSpinner spinner; -private JLabel todaysLabel; + private JLabel todaysLabel; // Fonts -private Font titleFont; -private Font dayOfWeekFont; -private Font dayFont; -private Font timeFont; -private Font todayFont; + private Font titleFont; + private Font dayOfWeekFont; + private Font dayFont; + private Font timeFont; + private Font todayFont; // Date formats -private DateFormat formatMonth; -private DateFormat formatWeekDay; + private DateFormat formatMonth; + private DateFormat formatWeekDay; -private String lastMonth; -private String lastYear; + private String lastMonth; + private String lastYear; // These maps are used to bind keyboard keys to methods -static InputMap inputMap = new InputMap(); -static ActionMap actionMap = new ActionMap(); + static InputMap inputMap = new InputMap(); + static ActionMap actionMap = new ActionMap(); // The input map maps a key to a name. The action map maps a name to // an action. The actions below map the action to a method call -private static Action yearBackward = new AbstractAction("yearBackward") { - public void actionPerformed(ActionEvent e) { - ((JCalendar)e.getSource()).yearBackward(); - } -}; - -private static Action yearForward = new AbstractAction("yearForward") { - public void actionPerformed(ActionEvent e) { - ((JCalendar)e.getSource()).yearForward(); - } -}; - -private static Action monthBackward = new AbstractAction("montBackward") { - public void actionPerformed(ActionEvent e) { - ((JCalendar)e.getSource()).monthBackward(); - } -}; - -private static Action monthForward = new AbstractAction("monthForward") { - public void actionPerformed(ActionEvent e) { - ((JCalendar)e.getSource()).monthForward(); - } -}; - -private static Action setNullDate = new AbstractAction("setNullDate") { - public void actionPerformed(ActionEvent e) { - ((JCalendar)e.getSource()).setDate(null); - } -}; + private static Action yearBackward = new AbstractAction("yearBackward") { + public void actionPerformed(ActionEvent e) { + ((JCalendar)e.getSource()).yearBackward(); + } + }; + + private static Action yearForward = new AbstractAction("yearForward") { + public void actionPerformed(ActionEvent e) { + ((JCalendar)e.getSource()).yearForward(); + } + }; + + private static Action monthBackward = new AbstractAction("montBackward") { + public void actionPerformed(ActionEvent e) { + ((JCalendar)e.getSource()).monthBackward(); + } + }; + + private static Action monthForward = new AbstractAction("monthForward") { + public void actionPerformed(ActionEvent e) { + ((JCalendar)e.getSource()).monthForward(); + } + }; + + private static Action setNullDate = new AbstractAction("setNullDate") { + public void actionPerformed(ActionEvent e) { + ((JCalendar)e.getSource()).setDate(null); + } + }; // The resource bundle -private static ResourceBundle bundle = - ResourceBundle.getBundle("org.freixas.jcalendar.Bundle"); + private static ResourceBundle bundle = + ResourceBundle.getBundle("org.freixas.jcalendar.Bundle"); //********************************************************************** // Static Constructors //********************************************************************** -static -{ - // Set up the input map that will be shared by all instances - - inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), "setNullDate"); - inputMap.put(KeyStroke.getKeyStroke("DELETE"), "setNullDate"); - inputMap.put(KeyStroke.getKeyStroke("shift LEFT"), "yearBackward"); - inputMap.put(KeyStroke.getKeyStroke("shift RIGHT"), "yearForward"); - inputMap.put(KeyStroke.getKeyStroke("LEFT"), "monthBackward"); - inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "monthForward"); - - actionMap.put("setNullDate", setNullDate); - actionMap.put("yearBackward", yearBackward); - actionMap.put("yearForward", yearForward); - actionMap.put("monthBackward", monthBackward); - actionMap.put("monthForward", monthForward); -} + static + { + // Set up the input map that will be shared by all instances + + inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), "setNullDate"); + inputMap.put(KeyStroke.getKeyStroke("DELETE"), "setNullDate"); + inputMap.put(KeyStroke.getKeyStroke("shift LEFT"), "yearBackward"); + inputMap.put(KeyStroke.getKeyStroke("shift RIGHT"), "yearForward"); + inputMap.put(KeyStroke.getKeyStroke("LEFT"), "monthBackward"); + inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "monthForward"); + + actionMap.put("setNullDate", setNullDate); + actionMap.put("yearBackward", yearBackward); + actionMap.put("yearForward", yearForward); + actionMap.put("monthBackward", monthBackward); + actionMap.put("monthForward", monthForward); + } //********************************************************************** // Constructors //********************************************************************** -/** - * Create an instance of JCalendar using the default calendar and - * locale. Display the date but not the time. Don't display today's - * date at the bottom of the panel. - */ - -public -JCalendar() -{ - this(Calendar.getInstance(), - Locale.getDefault(), - DISPLAY_DATE, - false, - null); -} - -/** - * Create an instance of JCalendar using the default calendar and - * locale. Display a calendar and/or a time spinner as requested (to - * display both use DISPLAY_DATE | DISPLAY_TIME). Display today's - * date if requested. Use the defult pattern to display the time in the - * time spinner field (if there is one). - * - * @param selectedComponents Use DISPLAY_DATE, DISPLAY_TIME or - * (DISPLAY_DATE | DISPLAY_TIME). - * @param isTodayDisplayed True if today's date should be displayed at - * the bottom of the panel. - */ - -public -JCalendar( - int selectedComponents, - boolean isTodayDisplayed) -{ - this(Calendar.getInstance(), - Locale.getDefault(), - selectedComponents, - isTodayDisplayed, - null); -} - -/** - * Create an instance of JCalendar using the given calendar and - * locale. Display a calendar and/or a time spinner as requested (to - * display both use DISPLAY_DATE | DISPLAY_TIME). Display today's - * date if requested. Use the default pattern to display the time in the - * time spinner field (if there is one). - * - * @param calendar The calendar to use. - * @param locale The locale to use. - * @param selectedComponents Use DISPLAY_DATE, DISPLAY_TIME or - * (DISPLAY_DATE | DISPLAY_TIME). - * @param isTodayDisplayed True if today's date should be displayed at - * the bottom of the panel. - */ - -public -JCalendar( - Calendar calendar, - Locale locale, - int selectedComponents, - boolean isTodayDisplayed) -{ - this(calendar, - locale, - selectedComponents, - isTodayDisplayed, - null); -} - -/** - * Create an instance of JCalendar using the given calendar and - * locale. Display a calendar and/or a time spinner as requested (to - * display both use DISPLAY_DATE | DISPLAY_TIME). Display today's - * date if requested. Set the pattern used to display the time in the time - * spinner field (if there is one). If null, use the default MEDIUM - * format for the given locale. Patterns are from DateFormat and - * SimpleDateFormat. - * - * @param calendar The calendar to use. - * @param locale The locale to use. - * @param selectedComponents Use DISPLAY_DATE, DISPLAY_TIME or - * (DISPLAY_DATE | DISPLAY_TIME). - * @param isTodayDisplayed True if today's date should be displayed at - * the bottom of the panel. - * @param timePattern The pattern used to display the time in the time - * spinner field. - * @see DateFormat - * @see SimpleDateFormat - */ + /** + * Create an instance of JCalendar using the default calendar and + * locale. Display the date but not the time. Don't display today's + * date at the bottom of the panel. + */ + + public + JCalendar() + { + this(Calendar.getInstance(), + Locale.getDefault(), + DISPLAY_DATE, + false, + null); + } -public -JCalendar( - Calendar calendar, - Locale locale, - int selectedComponents, - boolean isTodayDisplayed, - String timePattern) -{ - this.selectedCalendar = (Calendar)calendar.clone(); - this.displayCalendar = (Calendar)selectedCalendar.clone(); - this.selectedComponents = selectedComponents; - if ((selectedComponents & (DISPLAY_DATE | DISPLAY_TIME)) == 0) { - throw new IllegalStateException( - bundle.getString("IllegalStateException")); + /** + * Create an instance of JCalendar using the default calendar and + * locale. Display a calendar and/or a time spinner as requested (to + * display both use DISPLAY_DATE | DISPLAY_TIME). Display today's + * date if requested. Use the defult pattern to display the time in the + * time spinner field (if there is one). + * + * @param selectedComponents Use DISPLAY_DATE, DISPLAY_TIME or + * (DISPLAY_DATE | DISPLAY_TIME). + * @param isTodayDisplayed True if today's date should be displayed at + * the bottom of the panel. + */ + + public + JCalendar( + int selectedComponents, + boolean isTodayDisplayed) + { + this(Calendar.getInstance(), + Locale.getDefault(), + selectedComponents, + isTodayDisplayed, + null); } - this.locale = locale; - this.isTodayDisplayed = isTodayDisplayed; - - if ((selectedComponents & DISPLAY_TIME) > 0) { - if (timePattern == null) { - DateFormat timeFormat = - DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); - this.timePattern = "HH:mm:ss"; - if (timeFormat instanceof SimpleDateFormat) { - this.timePattern = ((SimpleDateFormat)timeFormat).toPattern(); - } - } - else { - this.timePattern = timePattern; - } + /** + * Create an instance of JCalendar using the given calendar and + * locale. Display a calendar and/or a time spinner as requested (to + * display both use DISPLAY_DATE | DISPLAY_TIME). Display today's + * date if requested. Use the default pattern to display the time in the + * time spinner field (if there is one). + * + * @param calendar The calendar to use. + * @param locale The locale to use. + * @param selectedComponents Use DISPLAY_DATE, DISPLAY_TIME or + * (DISPLAY_DATE | DISPLAY_TIME). + * @param isTodayDisplayed True if today's date should be displayed at + * the bottom of the panel. + */ + + public + JCalendar( + Calendar calendar, + Locale locale, + int selectedComponents, + boolean isTodayDisplayed) + { + this(calendar, + locale, + selectedComponents, + isTodayDisplayed, + null); } - createCalendarComponents(); - setDate(new Date()); -} + /** + * Create an instance of JCalendar using the given calendar and + * locale. Display a calendar and/or a time spinner as requested (to + * display both use DISPLAY_DATE | DISPLAY_TIME). Display today's + * date if requested. Set the pattern used to display the time in the time + * spinner field (if there is one). If null, use the default MEDIUM + * format for the given locale. Patterns are from DateFormat and + * SimpleDateFormat. + * + * @param calendar The calendar to use. + * @param locale The locale to use. + * @param selectedComponents Use DISPLAY_DATE, DISPLAY_TIME or + * (DISPLAY_DATE | DISPLAY_TIME). + * @param isTodayDisplayed True if today's date should be displayed at + * the bottom of the panel. + * @param timePattern The pattern used to display the time in the time + * spinner field. + * @see DateFormat + * @see SimpleDateFormat + */ + + public + JCalendar( + Calendar calendar, + Locale locale, + int selectedComponents, + boolean isTodayDisplayed, + String timePattern) + { + this.selectedCalendar = (Calendar)calendar.clone(); + this.displayCalendar = (Calendar)selectedCalendar.clone(); + this.selectedComponents = selectedComponents; + if ((selectedComponents & (DISPLAY_DATE | DISPLAY_TIME)) == 0) { + throw new IllegalStateException( + bundle.getString("IllegalStateException")); + } + + this.locale = locale; + this.isTodayDisplayed = isTodayDisplayed; + + if ((selectedComponents & DISPLAY_TIME) > 0) { + if (timePattern == null) { + DateFormat timeFormat = + DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); + this.timePattern = "HH:mm:ss"; + if (timeFormat instanceof SimpleDateFormat) { + this.timePattern = ((SimpleDateFormat)timeFormat).toPattern(); + } + } + else { + this.timePattern = timePattern; + } + } + + createCalendarComponents(); + setDate(new Date()); + } //********************************************************************** // Public //********************************************************************** -/** - * Add a date listener. This listener will receive events each time - * the selected date changes. - * - * @param listener The date listener to add. - */ - -public void -addDateListener( - DateListener listener) -{ - listenerList.add(DateListener.class, listener); -} - -/** - * Remove a date listener. - * - * @param listener The date listener to remove. - */ - -public void -removeDateListener( - DateListener listener) -{ - listenerList.remove(DateListener.class, listener); -} - -/** - * Get whether a null date is allowed. - * - * @return Whether a null date is allowed. - */ - -public boolean -isNullAllowed() -{ - return isNullAllowed; -} - -/** - * Set whether a null date is allowed. A null date means that no date - * is selected. The user can select a null date by pressing DELETE - * anywhere within the calendar. - *

- * If nulls are not allowed, a setDate(null) will be ignored without - * error. The DELETE key will do nothing. - *

- * If you switch from allowing nulls to not allowing nulls and the - * current date is null, it will remain null until a date is selected. - *

- * The component default is to allow nulls. - * - * @param isNullAllowed Whether a null date is allowed. - */ - -public void -setNullAllowed( - boolean isNullAllowed) -{ - this.isNullAllowed = isNullAllowed; -} - -/** - * Get the date currently displayed by the calendar panel. If no date - * is selected, null is returned. - * - * @return The date currently displayed. - * @see #getCalendar - */ - -public Date -getDate() -{ - if (isNullDate) return null; - return selectedCalendar.getTime(); -} - -/** - * Set the calendar panel to display the given date. This will fire a - * DateEvent. The date may be null. If isNullAllowed() is true, then - * all dates will be unselected. If isNullAllowed() is false, a null - * date is ignored. - * - * @param date The date to set. - */ - -public void -setDate( - Date date) -{ - if (date == null) { - - // Ignore nulls if nulls aren't allowed - - if (!isNullAllowed) return; - - if (!isNullDate) { - isNullDate = true; - selectedYear = -1; - selectedMonth = -1; - selectedDay = -1; - selectedCalendar.set(Calendar.YEAR, 9999); - selectedCalendar.set(Calendar.MONTH, 9); - selectedCalendar.set(Calendar.DATE, 9); - selectedCalendar.set(Calendar.HOUR_OF_DAY, 0); - selectedCalendar.set(Calendar.MINUTE, 0); - selectedCalendar.set(Calendar.SECOND, 0); - updateCalendarComponents(); - fireDateChange(); - } + /** + * Add a date listener. This listener will receive events each time + * the selected date changes. + * + * @param listener The date listener to add. + */ + + public void + addDateListener( + DateListener listener) + { + listenerList.add(DateListener.class, listener); } - else { - int oldYear = selectedYear; - int oldMonth = selectedMonth; - int oldDay = selectedDay; - int oldHour = selectedHour; - int oldMinute = selectedMinute; - int oldSecond = selectedSecond; - - selectedCalendar.setTime(date); - selectedYear = selectedCalendar.get(Calendar.YEAR); - selectedMonth = selectedCalendar.get(Calendar.MONTH); - selectedDay = selectedCalendar.get(Calendar.DATE); - selectedHour = selectedCalendar.get(Calendar.HOUR_OF_DAY); - selectedMinute = selectedCalendar.get(Calendar.MINUTE); - selectedSecond = selectedCalendar.get(Calendar.SECOND); - - if ((((selectedComponents & DISPLAY_DATE) > 0) && - oldDay != selectedDay || - oldMonth != selectedMonth || - oldYear != selectedYear) || - - (((selectedComponents & DISPLAY_TIME) > 0) && - oldHour != selectedHour || - oldMinute != selectedMinute || - oldSecond != selectedSecond)) { - - isNullDate = false; - displayCalendar.setTime(date); - updateCalendarComponents(); - fireDateChange(); - } + /** + * Remove a date listener. + * + * @param listener The date listener to remove. + */ + + public void + removeDateListener( + DateListener listener) + { + listenerList.remove(DateListener.class, listener); } -} - -/** - * Reset the displayed date without changing the selected date. No - * event occurs. A null date will reset to today's date. The display - * date simply selects the calendar page (month/year) to display. - * - * @param date The date to display. - */ -public void -setDisplayDate( - Date date) -{ - if (date == null) date = new Date(); + /** + * Get whether a null date is allowed. + * + * @return Whether a null date is allowed. + */ - displayCalendar.setTime(date); - int oldMonth = displayCalendar.get(Calendar.MONTH); - int oldYear = displayCalendar.get(Calendar.YEAR); - if (oldMonth != displayMonth || oldYear != displayYear) { - updateCalendarComponents(); + public boolean + isNullAllowed() + { + return isNullAllowed; } -} - -/** - * Get the pattern used to display the time in the time selection - * spinner. This is null if the time is not displayed. - * - * @return The pattern used to display the time in the time selection - * spinner. - */ -public String -getTimePattern() -{ - if ((selectedComponents & DISPLAY_TIME) != 0) { - return timePattern; + /** + * Set whether a null date is allowed. A null date means that no date + * is selected. The user can select a null date by pressing DELETE + * anywhere within the calendar. + *

+ * If nulls are not allowed, a setDate(null) will be ignored without + * error. The DELETE key will do nothing. + *

+ * If you switch from allowing nulls to not allowing nulls and the + * current date is null, it will remain null until a date is selected. + *

+ * The component default is to allow nulls. + * + * @param isNullAllowed Whether a null date is allowed. + */ + + public void + setNullAllowed( + boolean isNullAllowed) + { + this.isNullAllowed = isNullAllowed; } - return null; -} - -/** - * Get a copy of the calendar used by this JCalendar. This calendar - * will be set to the currently selected date, so it is an alternative - * to the getDate() method. If no date is selected (getDate() returns - * null), the calendar's selected date is 9/9/9999 and should not be - * used. - * - * @return A copy of the calendar used by JCalendar. - * @see #getDate - */ - -public Calendar -getCalendar() -{ - return (Calendar)selectedCalendar.clone(); -} - -/** - * Return the locale used by this JCalendar. - * - * @return The locale used by this JCalendar. - */ - -public Locale -getLocale() -{ - return locale; -} -/** - * Return the components being displayed: - * - * (getSelectedComponents() & DISPLAY_DATE) > 0 - * - * means that the date calendar is being displayed. - * - * (getSelectedComponents() & DISPLAY_TIME) > 0 - * - * menas that the time spinner field is being displayed. - * - * @return The selected components. - */ - -public int -getSelectedComponents() -{ - return selectedComponents; -} - - -/** - * Returns true if today's date is displayed at the bottom of the - * calendar. - * - * @return True if today's date is displayed at the bottom of the - * calendar. - */ + /** + * Get the date currently displayed by the calendar panel. If no date + * is selected, null is returned. + * + * @return The date currently displayed. + * @see #getCalendar + */ + + public Date + getDate() + { + if (isNullDate) return null; + return selectedCalendar.getTime(); + } -public boolean -isTodayDisplayed() -{ - return isTodayDisplayed; -} + /** + * Set the calendar panel to display the given date. This will fire a + * DateEvent. The date may be null. If isNullAllowed() is true, then + * all dates will be unselected. If isNullAllowed() is false, a null + * date is ignored. + * + * @param date The date to set. + */ + + public void + setDate( + Date date) + { + if (date == null) { + + // Ignore nulls if nulls aren't allowed + + if (!isNullAllowed) return; + + if (!isNullDate) { + isNullDate = true; + selectedYear = -1; + selectedMonth = -1; + selectedDay = -1; + selectedCalendar.set(Calendar.YEAR, 9999); + selectedCalendar.set(Calendar.MONTH, 9); + selectedCalendar.set(Calendar.DATE, 9); + selectedCalendar.set(Calendar.HOUR_OF_DAY, 0); + selectedCalendar.set(Calendar.MINUTE, 0); + selectedCalendar.set(Calendar.SECOND, 0); + updateCalendarComponents(); + fireDateChange(); + } + } + + else { + int oldYear = selectedYear; + int oldMonth = selectedMonth; + int oldDay = selectedDay; + int oldHour = selectedHour; + int oldMinute = selectedMinute; + int oldSecond = selectedSecond; + + selectedCalendar.setTime(date); + selectedYear = selectedCalendar.get(Calendar.YEAR); + selectedMonth = selectedCalendar.get(Calendar.MONTH); + selectedDay = selectedCalendar.get(Calendar.DATE); + selectedHour = selectedCalendar.get(Calendar.HOUR_OF_DAY); + selectedMinute = selectedCalendar.get(Calendar.MINUTE); + selectedSecond = selectedCalendar.get(Calendar.SECOND); + + if ((((selectedComponents & DISPLAY_DATE) > 0) && + oldDay != selectedDay || + oldMonth != selectedMonth || + oldYear != selectedYear) || + + (((selectedComponents & DISPLAY_TIME) > 0) && + oldHour != selectedHour || + oldMinute != selectedMinute || + oldSecond != selectedSecond)) { + + isNullDate = false; + displayCalendar.setTime(date); + updateCalendarComponents(); + fireDateChange(); + } + } + } -/** - * Get the title font. - * - * @return The title font. - */ + /** + * Reset the displayed date without changing the selected date. No + * event occurs. A null date will reset to today's date. The display + * date simply selects the calendar page (month/year) to display. + * + * @param date The date to display. + */ + + public void + setDisplayDate( + Date date) + { + if (date == null) date = new Date(); + + displayCalendar.setTime(date); + int oldMonth = displayCalendar.get(Calendar.MONTH); + int oldYear = displayCalendar.get(Calendar.YEAR); + if (oldMonth != displayMonth || oldYear != displayYear) { + updateCalendarComponents(); + } + } -public Font -getTitleFont() -{ - return titleFont; -} + /** + * Get the pattern used to display the time in the time selection + * spinner. This is null if the time is not displayed. + * + * @return The pattern used to display the time in the time selection + * spinner. + */ + + public String + getTimePattern() + { + if ((selectedComponents & DISPLAY_TIME) != 0) { + return timePattern; + } + return null; + } -/** - * If the font is set to null, then the title font (for the Month Year - * title) will default to the L&F's Label default font. - *

- * Otherwise, the title font is set as given. - * - * @param font The font to set. - */ + /** + * Get a copy of the calendar used by this JCalendar. This calendar + * will be set to the currently selected date, so it is an alternative + * to the getDate() method. If no date is selected (getDate() returns + * null), the calendar's selected date is 9/9/9999 and should not be + * used. + * + * @return A copy of the calendar used by JCalendar. + * @see #getDate + */ + + public Calendar + getCalendar() + { + return (Calendar)selectedCalendar.clone(); + } -public void -setTitleFont( - Font font) -{ - if (font == null && titleFont != null || - !font.equals(titleFont)) { + /** + * Return the locale used by this JCalendar. + * + * @return The locale used by this JCalendar. + */ - titleFont = font; - if (isDisplayable()) setupTitleFont(); + public Locale + getLocale() + { + return locale; } -} -/** - * Get the day-of-week font (Mon, Tue, etc.). - * - * @return The day-of-week font. - */ - -public Font -getDayOfWeekFont() -{ - return dayOfWeekFont; -} + /** + * Return the components being displayed: + * + * (getSelectedComponents() & DISPLAY_DATE) > 0 + * + * means that the date calendar is being displayed. + * + * (getSelectedComponents() & DISPLAY_TIME) > 0 + * + * menas that the time spinner field is being displayed. + * + * @return The selected components. + */ + + public int + getSelectedComponents() + { + return selectedComponents; + } -/** - * If the font is set to null, then the day-of-week font (Mon, Tue, - * etc.) will default to 9/11th's of the L&F's Label default font. - *

- * Otherwise, the day-of-week font is set as given. - * - * @param font The font to set. - */ -public void -setDayOfWeekFont( - Font font) -{ - if (font == null && dayOfWeekFont != null || - !font.equals(dayOfWeekFont)) { + /** + * Returns true if today's date is displayed at the bottom of the + * calendar. + * + * @return True if today's date is displayed at the bottom of the + * calendar. + */ - dayOfWeekFont = font; - if (isDisplayable()) setupDayOfWeekFonts(); + public boolean + isTodayDisplayed() + { + return isTodayDisplayed; } -} -/** - * Get the day font. - * - * @return The day font. - */ + /** + * Get the title font. + * + * @return The title font. + */ -public Font -getDayFont() -{ - return dayFont; -} + public Font + getTitleFont() + { + return titleFont; + } -/** - * If the font is set to null, then the day font will default to - * 9/11th's of the L&F's Button default font. - *

- * Otherwise, the day font is set as given. - * - * @param font The font to set. - */ + /** + * If the font is set to null, then the title font (for the Month Year + * title) will default to the L&F's Label default font. + *

+ * Otherwise, the title font is set as given. + * + * @param font The font to set. + */ + + public void + setTitleFont( + Font font) + { + if (font == null && titleFont != null || + !font.equals(titleFont)) { + + titleFont = font; + if (isDisplayable()) setupTitleFont(); + } + } -public void -setDayFont( - Font font) -{ - if (font == null && dayFont != null || - !font.equals(dayFont)) { + /** + * Get the day-of-week font (Mon, Tue, etc.). + * + * @return The day-of-week font. + */ - dayFont = font; - if (isDisplayable()) setupDayFonts(); + public Font + getDayOfWeekFont() + { + return dayOfWeekFont; } -} -/** - * Get the time spinner font. - * - * @return The time spinner font. - */ + /** + * If the font is set to null, then the day-of-week font (Mon, Tue, + * etc.) will default to 9/11th's of the L&F's Label default font. + *

+ * Otherwise, the day-of-week font is set as given. + * + * @param font The font to set. + */ + + public void + setDayOfWeekFont( + Font font) + { + if (font == null && dayOfWeekFont != null || + !font.equals(dayOfWeekFont)) { + + dayOfWeekFont = font; + if (isDisplayable()) setupDayOfWeekFonts(); + } + } -public Font -getTimeFont() -{ - return timeFont; -} + /** + * Get the day font. + * + * @return The day font. + */ -/** - * If the font is set to null, then the time spinner font will default - * to the L&F's Spinner default font. - *

- * Otherwise, the time spinner font is set as given. - * - * @param font The font to set. - */ - -public void -setTimeFont( - Font font) -{ - if (font == null && timeFont != null || - !font.equals(timeFont)) { + public Font + getDayFont() + { + return dayFont; + } - timeFont = font; - if (isDisplayable()) setupTimeFont(); + /** + * If the font is set to null, then the day font will default to + * 9/11th's of the L&F's Button default font. + *

+ * Otherwise, the day font is set as given. + * + * @param font The font to set. + */ + + public void + setDayFont( + Font font) + { + if (font == null && dayFont != null || + !font.equals(dayFont)) { + + dayFont = font; + if (isDisplayable()) setupDayFonts(); + } } -} -/** - * Get the font used to display today's date as text. - * - * @return The font used to display today's date. - */ + /** + * Get the time spinner font. + * + * @return The time spinner font. + */ -public Font -getTodayFont() -{ - return todayFont; -} + public Font + getTimeFont() + { + return timeFont; + } -/** - * If the font is set to null, then the font used to display today's - * date as text will default to the L&F's Label default font. - *

- * Otherwise, the font used to display today's date is set as given. - * - * @param font The font to set. - */ + /** + * If the font is set to null, then the time spinner font will default + * to the L&F's Spinner default font. + *

+ * Otherwise, the time spinner font is set as given. + * + * @param font The font to set. + */ + + public void + setTimeFont( + Font font) + { + if (font == null && timeFont != null || + !font.equals(timeFont)) { + + timeFont = font; + if (isDisplayable()) setupTimeFont(); + } + } -public void -setTodayFont( - Font font) -{ - if (font == null && todayFont != null || - !font.equals(todayFont)) { + /** + * Get the font used to display today's date as text. + * + * @return The font used to display today's date. + */ - todayFont = font; - if (isDisplayable()) setupTodayFont(); + public Font + getTodayFont() + { + return todayFont; } -} -/** - * {@inheritDoc} - */ + /** + * If the font is set to null, then the font used to display today's + * date as text will default to the L&F's Label default font. + *

+ * Otherwise, the font used to display today's date is set as given. + * + * @param font The font to set. + */ + + public void + setTodayFont( + Font font) + { + if (font == null && todayFont != null || + !font.equals(todayFont)) { + + todayFont = font; + if (isDisplayable()) setupTodayFont(); + } + } -public void -setEnabled( - boolean b) -{ - if (b != isEnabled()) { - super.setEnabled(b); - - if ((selectedComponents & DISPLAY_DATE) > 0) { - yearDecrButton.setEnabled(b); - monthDecrButton.setEnabled(b); - monthYearLabel.setEnabled(b); - monthIncrButton.setEnabled(b); - yearIncrButton.setEnabled(b); - - for (int day = 0; day < 7; day++) { - dayOfWeekLabels[day].setEnabled(b); - } - - for (int row = 0; row < 6; row++) { - for (int day = 0; day < 7; day++) { - if (dayButtons[row][day].getText().length() > 0) { - dayButtons[row][day].setEnabled(b); - } - } - } - } - - if ((selectedComponents & DISPLAY_TIME) > 0) { - spinner.setEnabled(b); - } + /** + * {@inheritDoc} + */ + + public void + setEnabled( + boolean b) + { + if (b != isEnabled()) { + super.setEnabled(b); + + if ((selectedComponents & DISPLAY_DATE) > 0) { + yearDecrButton.setEnabled(b); + monthDecrButton.setEnabled(b); + monthYearLabel.setEnabled(b); + monthIncrButton.setEnabled(b); + yearIncrButton.setEnabled(b); + + for (int day = 0; day < 7; day++) { + dayOfWeekLabels[day].setEnabled(b); + } + + for (int row = 0; row < 6; row++) { + for (int day = 0; day < 7; day++) { + if (dayButtons[row][day].getText().length() > 0) { + dayButtons[row][day].setEnabled(b); + } + } + } + } + + if ((selectedComponents & DISPLAY_TIME) > 0) { + spinner.setEnabled(b); + } + } } -} -/** - * {@inheritDoc} - */ + /** + * {@inheritDoc} + */ -public void -addNotify() -{ - // We don't try to do anything with the fonts until we know the - // component is displayable + public void + addNotify() + { + // We don't try to do anything with the fonts until we know the + // component is displayable - setupTitleFont(); - setupDayOfWeekFonts(); - setupDayFonts(); - setupTimeFont(); - setupTodayFont(); + setupTitleFont(); + setupDayOfWeekFonts(); + setupDayFonts(); + setupTimeFont(); + setupTodayFont(); - super.addNotify(); -} + super.addNotify(); + } // The default equals and hashCode methods are acceptable. In // general, two components are never equal unless they are the same // component. -/** - * {@inheritDoc} - */ - -protected String -paramString() -{ - String curDate; - if ((selectedComponents & DISPLAY_DATE) == DISPLAY_DATE) { - curDate = DateFormat.getDateInstance( - DateFormat.FULL, locale).format(getDate()); - } - else if ((selectedComponents & DISPLAY_TIME) == DISPLAY_TIME) { - curDate = DateFormat.getTimeInstance( - DateFormat.FULL, locale).format(getDate()); - } - else { - curDate = DateFormat.getDateTimeInstance( - DateFormat.FULL, DateFormat.FULL, locale).format(getDate()); + /** + * {@inheritDoc} + */ + + protected String + paramString() + { + String curDate; + if ((selectedComponents & DISPLAY_DATE) == DISPLAY_DATE) { + curDate = DateFormat.getDateInstance( + DateFormat.FULL, locale).format(getDate()); + } + else if ((selectedComponents & DISPLAY_TIME) == DISPLAY_TIME) { + curDate = DateFormat.getTimeInstance( + DateFormat.FULL, locale).format(getDate()); + } + else { + curDate = DateFormat.getDateTimeInstance( + DateFormat.FULL, DateFormat.FULL, locale).format(getDate()); + } + + return super.paramString() + ",selectedDate=" + curDate; } - return super.paramString() + ",selectedDate=" + curDate; -} - //********************************************************************** // Package Public //********************************************************************** -private JCalendarCombo comboCalendar; - -/** - * Get the JCalendarCombo component which uses this JCalendar in its - * combo popup. - * - * @return The JCalendarCombo component which uses this JCalendar in - * its combo popup. - * @see JCalendarCombo - */ - -JCalendarCombo -getJCalendarComboParent() -{ - return comboCalendar; -} - -/** - * Set the JCalendarCombo component which uses this JCalendar in its - * combo popup. - * - * @param comboCalendar The JCalendarCombo component which uses this - * JCalendar in its combo popup. - * @see JCalendarCombo - */ - -void -setJCalendarComboParent( - JCalendarCombo comboCalendar) -{ - this.comboCalendar = comboCalendar; -} + private JCalendarCombo comboCalendar; + + /** + * Get the JCalendarCombo component which uses this JCalendar in its + * combo popup. + * + * @return The JCalendarCombo component which uses this JCalendar in + * its combo popup. + * @see JCalendarCombo + */ + + JCalendarCombo + getJCalendarComboParent() + { +