org.jdesktop.swingx.calendar
Class JXMonthView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.jdesktop.swingx.calendar.JXMonthView
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class JXMonthView
extends JComponent

Component that displays a month calendar which can be used to select a day or range of days. By default the JXMonthView will display a single calendar using the current month and year, using Calendar.SUNDAY as the first day of the week.

The JXMonthView can be configured to display more than one calendar at a time by calling setPreferredCalCols/setPreferredCalRows. These methods will set the preferred number of calendars to use in each column/row. As these values change, the Dimension returned from getMinimumSize and getPreferredSize will be updated. The following example shows how to create a 2x2 view which is contained within a JFrame:

     JXMonthView monthView = new JXMonthView();
     monthView.setPreferredCols(2);
     monthView.setPreferredRows(2);

     JFrame frame = new JFrame();
     frame.getContentPane().add(monthView);
     frame.pack();
     frame.setVisible(true);
 

JXMonthView can be further configured to allow any day of the week to be considered the first day of the week. Character representation of those days may also be set by providing an array of strings.

    monthView.setFirstDayOfWeek(Calendar.MONDAY);
    monthView.setDaysOfTheWeek(
            new String[]{"S", "M", "T", "W", "Th", "F", "S"});
 

This component supports flagging days. These flagged days are displayed in a bold font. This can be used to inform the user of such things as scheduled appointment.

    // Create some dates that we want to flag as being important.
    Calendar cal1 = Calendar.getInstance();
    cal1.set(2004, 1, 1);
    Calendar cal2 = Calendar.getInstance();
    cal2.set(2004, 1, 5);

    long[] flaggedDates = new long[] {
        cal1.getTimeInMillis(),
        cal2.getTimeInMillis(),
        System.currentTimeMillis()
    };

    monthView.setFlaggedDates(flaggedDates);
 
Applications may have the need to allow users to select different ranges of dates. There are four modes of selection that are supported, single, multiple, week and no selection. Once a selection is made an action is fired, with exception of the no selection mode, to inform listeners that selection has changed.
    // Change the selection mode to select full weeks.
    monthView.setSelectionMode(JXMonthView.WEEK_INTERVAL_SELECTION);

    // Add an action listener that will be notified when the user
    // changes selection via the mouse.
    monthView.getSelectionModel().addDateSelectionListener(new DateSelectionListener {
        public void valueChanged(DateSelectionEvent e) {
            System.out.println(e.getSelection());
        }
    });
 

See Also:
Serialized Form

Nested Class Summary
static class JXMonthView.SelectionMode
           
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Insets _monthStringInsets
          Insets used in determining the rectangle for the month string background.
static String BOX_PADDING_X
           
static String BOX_PADDING_Y
           
static int DAYS_IN_WEEK
           
static String DAYS_OF_THE_WEEK
           
static String ENSURE_DATE_VISIBILITY
           
static String FIRST_DISPLAYED_DATE
           
static String FIRST_DISPLAYED_MONTH
           
static String FIRST_DISPLAYED_YEAR
           
static String FLAGGED_DATES
           
static int MONTH_DOWN
          Return value used to identify when the month down button is pressed.
static int MONTH_UP
          Return value used to identify when the month up button is pressed.
static int MONTHS_IN_YEAR
           
static String SELECTION_MODEL
           
static String SHOW_LEADING_DATES
           
static String SHOW_TRAILING_DATES
           
static String TRAVERSABLE
           
static String uiClassID
          UI Class ID
static String WEEK_NUMBER
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JXMonthView()
          Create a new instance of the JXMonthView class using the month and year of the current day as the first date to display.
JXMonthView(long firstDisplayedDate)
          Create a new instance of the JXMonthView class using the month and year from initialTime as the first date to display.
JXMonthView(long firstDisplayedDate, DateSelectionModel model)
           
 
Method Summary
 void addActionListener(ActionListener l)
          Adds an ActionListener.
 void addNotify()
          Notifies this component that it now has a parent component.
 void addSelectionInterval(Date startDate, Date endDate)
          Adds the selection interval to the selection model.
 void clearSelection()
           
 void ensureDateVisible(long date)
          Moves the date into the visible region of the calendar.
protected  void fireActionPerformed()
          Fires an ActionEvent to all listeners.
 String getActionCommand()
          Returns the string currently used to identiy fired ActionEvents.
 int getBoxPaddingX()
          Returns the padding used between days in the calendar.
 int getBoxPaddingY()
          Returns the padding used above and below days in the calendar.
 Calendar getCalendar()
           
 long getDayAt(int x, int y)
          Return a long representing the date at the specified x/y position.
 Color getDayForeground(int dayOfWeek)
          Return the color that should be used for painting the numerical day of the week.
 String[] getDaysOfTheWeek()
          Returns the single character representation for each day of the week.
 Color getDaysOfTheWeekForeground()
           
 int getFirstDayOfWeek()
          Gets what the first day of the week is; e.g., Calendar.SUNDAY in the U.S., Calendar.MONDAY in France.
 long getFirstDisplayedDate()
          Returns the first displayed date.
 Color getFlaggedDayForeground()
          Return the color that should be used for painting the foreground of the flagged day.
 long getLastDisplayedDate()
          Returns the last date able to be displayed.
<T extends EventListener>
T[]
getListeners(Class<T> listenerType)
          Returns an array of all the objects currently registered as FooListeners upon this JComponent.
 Color getMonthStringBackground()
          Returns the color used to paint the month string background.
 Color getMonthStringForeground()
          Returns the color used to paint the month string foreground.
 Insets getMonthStringInsets()
          Returns a copy of the insets used to paint the month string background.
 int getPreferredCols()
          Returns the preferred number of columns to paint calendars in.
 int getPreferredRows()
          Returns the preferred number of rows to paint calendars in.
 Color getSelectedBackground()
          Returns the selected background color.
 DateSpan getSelectedDateSpan()
          Deprecated. see #getSelection
 SortedSet<Date> getSelection()
           
 JXMonthView.SelectionMode getSelectionMode()
          Returns the current selection mode for this JXMonthView.
 DateSelectionModel getSelectionModel()
           
 TimeZone getTimeZone()
          Gets the time zone.
 Color getTodayBackground()
          Returns the color used when painting the today background.
 MonthViewUI getUI()
           
 String getUIClassID()
          Returns the UIDefaults key used to look up the name of the swing.plaf.ComponentUI class that defines the look and feel for this component.
 boolean isAntialiased()
          Returns true if anti-aliased text is enabled for this component, false otherwise.
 boolean isFlaggedDate(long date)
          Identifies whether or not the date passed is a flagged date.
 boolean isSelectedDate(long date)
          Returns true if the specified date falls within the _startSelectedDate and _endSelectedDate range.
 boolean isShowingLeadingDates()
          Whether or not we're showing leading dates.
 boolean isShowingTrailingDates()
          Whether or not we're showing trailing dates.
 boolean isShowingWeekNumber()
          Returns whether or not this JXMonthView should display week number.
 boolean isTraversable()
          Returns whether or not the month view supports traversing months.
 boolean isUnselectableDate(long date)
          Identifies whether or not the date passed is an unselectable date.
static void main(String[] args)
           
 void postActionEvent()
           
 void removeActionListener(ActionListener l)
          Removes an ActionListener.
 void removeNotify()
          Notifies this component that it no longer has a parent component.
 void removeSelectionInterval(Date startDate, Date endDate)
          Removes the selection interval from the selection model.
 void setActionCommand(String actionCommand)
          Sets the string used to identify fired ActionEvents.
 void setAntialiased(boolean antiAlias)
          Turns on/off anti-aliased text for this component.
 void setBounds(Rectangle r)
          Moves and resizes this component to conform to the new bounding rectangle r.
 void setBoxPaddingX(int boxPaddingX)
          Sets the number of pixels used to pad the left and right side of a day.
 void setBoxPaddingY(int boxPaddingY)
          Sets the number of pixels used to pad the top and bottom of a day.
 void setDayForeground(int dayOfWeek, Color c)
          Set the color to be used for painting the specified day of the week.
 void setDaysOfTheWeek(String[] days)
          Sets the single character representation for each day of the week.
 void setDaysOfTheWeekForeground(Color c)
          Sets the color used to draw the foreground of each day of the week.
 void setFirstDayOfWeek(int firstDayOfWeek)
          Sets what the first day of the week is; e.g., Calendar.SUNDAY in US, Calendar.MONDAY in France.
 void setFirstDisplayedDate(long date)
          Set the first displayed date.
 void setFlaggedDates(long[] flaggedDates)
          An array of longs defining days that should be flagged.
 void setFlaggedDayForeground(Color c)
          Set the color to be used for painting the foreground of a flagged day.
 void setFont(Font font)
          Sets the font of this component.
 void setMonthStringBackground(Color c)
          Sets the color used to draw the background of the month string.
 void setMonthStringForeground(Color c)
          Sets the color used to draw the foreground of the month string.
 void setMonthStringInsets(Insets insets)
          Insets used to modify the width/height when painting the background of the month string area.
 void setPreferredCols(int cols)
          The preferred number of columns to paint calendars.
 void setPreferredRows(int rows)
          Sets the preferred number of rows to paint calendars.
 void setSelectedBackground(Color c)
          Sets the selected background color to c.
 void setSelectedDateSpan(DateSpan dateSpan)
          Deprecated. see #setSelectionInterval
 void setSelectionInterval(Date startDate, Date endDate)
          Sets the selection interval to the selection model.
 void setSelectionMode(JXMonthView.SelectionMode selectionMode)
          Set the selection mode for this JXMonthView.
 void setSelectionModel(DateSelectionModel model)
           
 void setShowingWeekNumber(boolean showWeekNumber)
          Set whether or not this JXMonthView will display week numbers or not.
 void setShowLeadingDates(boolean value)
          Whether or not to show leading dates for a months displayed by this component.
 void setShowTrailingDates(boolean value)
          Whether or not to show trailing dates for the months displayed by this component.
 void setTimeZone(TimeZone tz)
          Sets the time zone with the given time zone value.
 void setTodayBackground(Color c)
          Sets the color used to draw the bounding box around today.
 void setTraversable(boolean traversable)
          Set whether or not the month view will display buttons to allow the user to traverse to previous or next months.
 void setUI(MonthViewUI ui)
          Sets the L&F object that renders this component.
 void setUnselectableDates(long[] unselectableDates)
          An array of longs defining days that should be unselectable.
 void updateUI()
          Resets the UI property with the value from the current look and feel.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BOX_PADDING_X

public static final String BOX_PADDING_X
See Also:
Constant Field Values

BOX_PADDING_Y

public static final String BOX_PADDING_Y
See Also:
Constant Field Values

DAYS_OF_THE_WEEK

public static final String DAYS_OF_THE_WEEK
See Also:
Constant Field Values

ENSURE_DATE_VISIBILITY

public static final String ENSURE_DATE_VISIBILITY
See Also:
Constant Field Values

FIRST_DISPLAYED_DATE

public static final String FIRST_DISPLAYED_DATE
See Also:
Constant Field Values

FIRST_DISPLAYED_MONTH

public static final String FIRST_DISPLAYED_MONTH
See Also:
Constant Field Values

FIRST_DISPLAYED_YEAR

public static final String FIRST_DISPLAYED_YEAR
See Also:
Constant Field Values

SELECTION_MODEL

public static final String SELECTION_MODEL
See Also:
Constant Field Values

SHOW_LEADING_DATES

public static final String SHOW_LEADING_DATES
See Also:
Constant Field Values

SHOW_TRAILING_DATES

public static final String SHOW_TRAILING_DATES
See Also:
Constant Field Values

TRAVERSABLE

public static final String TRAVERSABLE
See Also:
Constant Field Values

WEEK_NUMBER

public static final String WEEK_NUMBER
See Also:
Constant Field Values

FLAGGED_DATES

public static final String FLAGGED_DATES
See Also:
Constant Field Values

MONTH_DOWN

public static final int MONTH_DOWN
Return value used to identify when the month down button is pressed.

See Also:
Constant Field Values

MONTH_UP

public static final int MONTH_UP
Return value used to identify when the month up button is pressed.

See Also:
Constant Field Values

uiClassID

public static final String uiClassID
UI Class ID

See Also:
Constant Field Values

DAYS_IN_WEEK

public static final int DAYS_IN_WEEK
See Also:
Constant Field Values

MONTHS_IN_YEAR

public static final int MONTHS_IN_YEAR
See Also:
Constant Field Values

_monthStringInsets

protected Insets _monthStringInsets
Insets used in determining the rectangle for the month string background.

Constructor Detail

JXMonthView

public JXMonthView()
Create a new instance of the JXMonthView class using the month and year of the current day as the first date to display.


JXMonthView

public JXMonthView(long firstDisplayedDate)
Create a new instance of the JXMonthView class using the month and year from initialTime as the first date to display.

Parameters:
firstDisplayedDate - The first month to display.

JXMonthView

public JXMonthView(long firstDisplayedDate,
                   DateSelectionModel model)
Method Detail

getUI

public MonthViewUI getUI()

setUI

public void setUI(MonthViewUI ui)
Sets the L&F object that renders this component.

Parameters:
ui - UI to use for this JXMonthView

updateUI

public void updateUI()
Resets the UI property with the value from the current look and feel.

Overrides:
updateUI in class JComponent
See Also:
UIManager.getUI(javax.swing.JComponent)

getUIClassID

public String getUIClassID()
Description copied from class: javax.swing.JComponent
Returns the UIDefaults key used to look up the name of the swing.plaf.ComponentUI class that defines the look and feel for this component. Most applications will never need to call this method. Subclasses of JComponent that support pluggable look and feel should override this method to return a UIDefaults key that maps to the ComponentUI subclass that defines their look and feel.

Overrides:
getUIClassID in class JComponent
Returns:
the UIDefaults key for a ComponentUI subclass
See Also:
UIDefaults.getUI(javax.swing.JComponent)

getFirstDisplayedDate

public long getFirstDisplayedDate()
Returns the first displayed date.

Returns:
long The first displayed date.

setFirstDisplayedDate

public void setFirstDisplayedDate(long date)
Set the first displayed date. We only use the month and year of this date. The Calendar.DAY_OF_MONTH field is reset to 1 and all other fields, with exception of the year and month, are reset to 0.

Parameters:
date - The first displayed date.

getLastDisplayedDate

public long getLastDisplayedDate()
Returns the last date able to be displayed. For example, if the last visible month was April the time returned would be April 30, 23:59:59.

Returns:
long The last displayed date.

ensureDateVisible

public void ensureDateVisible(long date)
Moves the date into the visible region of the calendar. If the date is greater than the last visible date it will become the last visible date. While if it is less than the first visible date it will become the first visible date.

Parameters:
date - Date to make visible.

getSelectedDateSpan

@Deprecated
public DateSpan getSelectedDateSpan()
Deprecated. see #getSelection

Returns a date span of the selected dates. The result will be null if no dates are selected.

Returns:
Date span of the selected dates.

setSelectedDateSpan

@Deprecated
public void setSelectedDateSpan(DateSpan dateSpan)
Deprecated. see #setSelectionInterval

Selects the dates in the DateSpan. This method will not change the initial date displayed so the caller must update this if necessary. If we are in SINGLE_SELECTION mode only the start time from the DateSpan will be used. If we are in WEEK_INTERVAL_SELECTION mode the span will be modified to be valid if necessary.

Parameters:
dateSpan - DateSpan defining the selected dates. Passing null will clear the selection.

clearSelection

public void clearSelection()

getSelection

public SortedSet<Date> getSelection()

addSelectionInterval

public void addSelectionInterval(Date startDate,
                                 Date endDate)
Adds the selection interval to the selection model. All dates are modified to remove their hour of day, minute, second, and millisecond before being added to the selection model.

Parameters:
startDate - Start of date range to add to the selection
endDate - End of date range to add to the selection

setSelectionInterval

public void setSelectionInterval(Date startDate,
                                 Date endDate)
Sets the selection interval to the selection model. All dates are modified to remove their hour of day, minute, second, and millisecond before being added to the selection model.

Parameters:
startDate - Start of date range to set the selection to
endDate - End of date range to set the selection to

removeSelectionInterval

public void removeSelectionInterval(Date startDate,
                                    Date endDate)
Removes the selection interval from the selection model. All dates are modified to remove their hour of day, minute, second, and millisecond before being added to the selection model.

Parameters:
startDate - Start of the date range to remove from the selection
endDate - End of the date range to remove from the selection

getSelectionModel

public DateSelectionModel getSelectionModel()

setSelectionModel

public void setSelectionModel(DateSelectionModel model)

getSelectionMode

public JXMonthView.SelectionMode getSelectionMode()
Returns the current selection mode for this JXMonthView.

Returns:
int Selection mode.

setSelectionMode

public void setSelectionMode(JXMonthView.SelectionMode selectionMode)
Set the selection mode for this JXMonthView.

Parameters:
selectionMode - The selection mode to use for this JXMonthView

isSelectedDate

public boolean isSelectedDate(long date)
Returns true if the specified date falls within the _startSelectedDate and _endSelectedDate range. All dates are modified to remove their hour of day, minute, second, and millisecond before being added to the selection model.

Parameters:
date - The date to check
Returns:
true if the date is selected, false otherwise

isUnselectableDate

public boolean isUnselectableDate(long date)
Identifies whether or not the date passed is an unselectable date. All dates are modified to remove their hour of day, minute, second, and millisecond before being added to the selection model.

Parameters:
date - date which to test for unselectable status
Returns:
true if the date is unselectable, false otherwise

isFlaggedDate

public boolean isFlaggedDate(long date)
Identifies whether or not the date passed is a flagged date. All dates are modified to remove their hour of day, minute, second, and millisecond before being added to the selection model

Parameters:
date - date which to test for flagged status
Returns:
true if the date is flagged, false otherwise

setFlaggedDates

public void setFlaggedDates(long[] flaggedDates)
An array of longs defining days that should be flagged.

Parameters:
flaggedDates - the dates to be flagged

setUnselectableDates

public void setUnselectableDates(long[] unselectableDates)
An array of longs defining days that should be unselectable. All dates are modified to remove their hour of day, minute, second, and millisecond before being added to the selection model.

Parameters:
unselectableDates - the dates that should be unselectable

setShowLeadingDates

public void setShowLeadingDates(boolean value)
Whether or not to show leading dates for a months displayed by this component.

Parameters:
value - true if leading dates should be displayed, false otherwise.

isShowingLeadingDates

public boolean isShowingLeadingDates()
Whether or not we're showing leading dates.

Returns:
true if leading dates are shown, false otherwise.

setShowTrailingDates

public void setShowTrailingDates(boolean value)
Whether or not to show trailing dates for the months displayed by this component.

Parameters:
value - true if trailing dates should be displayed, false otherwise.

isShowingTrailingDates

public boolean isShowingTrailingDates()
Whether or not we're showing trailing dates.

Returns:
true if trailing dates are shown, false otherwise.

getBoxPaddingX

public int getBoxPaddingX()
Returns the padding used between days in the calendar.

Returns:
Padding used between days in the calendar

setBoxPaddingX

public void setBoxPaddingX(int boxPaddingX)
Sets the number of pixels used to pad the left and right side of a day. The padding is applied to both sides of the days. Therefore, if you used the padding value of 3, the number of pixels between any two days would be 6.

Parameters:
boxPaddingX - Number of pixels applied to both sides of a day

getBoxPaddingY

public int getBoxPaddingY()
Returns the padding used above and below days in the calendar.

Returns:
Padding used between dats in the calendar

setBoxPaddingY

public void setBoxPaddingY(int boxPaddingY)
Sets the number of pixels used to pad the top and bottom of a day. The padding is applied to both the top and bottom of a day. Therefore, if you used the padding value of 3, the number of pixels between any two days would be 6.

Parameters:
boxPaddingY - Number of pixels applied to top and bottom of a day

isTraversable

public boolean isTraversable()
Returns whether or not the month view supports traversing months.

Returns:
true if month traversing is enabled.

setTraversable

public void setTraversable(boolean traversable)
Set whether or not the month view will display buttons to allow the user to traverse to previous or next months.

Parameters:
traversable - set to true to enable month traversing, false otherwise.

isShowingWeekNumber

public boolean isShowingWeekNumber()
Returns whether or not this JXMonthView should display week number.

Returns:
true if week numbers should be displayed

setShowingWeekNumber

public void setShowingWeekNumber(boolean showWeekNumber)
Set whether or not this JXMonthView will display week numbers or not.

Parameters:
showWeekNumber - true if week numbers should be displayed, false otherwise

setDaysOfTheWeek

public void setDaysOfTheWeek(String[] days)
                      throws IllegalArgumentException,
                             NullPointerException
Sets the single character representation for each day of the week. For this method the first days of the week days[0] is assumed to be Calendar.SUNDAY.

Parameters:
days - Array of characters that represents each day
Throws:
IllegalArgumentException - if days.length != DAYS_IN_WEEK
NullPointerException - if days == null

getDaysOfTheWeek

public String[] getDaysOfTheWeek()
Returns the single character representation for each day of the week.

Returns:
Single character representation for the days of the week

getFirstDayOfWeek

public int getFirstDayOfWeek()
Gets what the first day of the week is; e.g., Calendar.SUNDAY in the U.S., Calendar.MONDAY in France.

Returns:
int The first day of the week.

setFirstDayOfWeek

public void setFirstDayOfWeek(int firstDayOfWeek)
Sets what the first day of the week is; e.g., Calendar.SUNDAY in US, Calendar.MONDAY in France.

Parameters:
firstDayOfWeek - The first day of the week.
See Also:
Calendar

getTimeZone

public TimeZone getTimeZone()
Gets the time zone.

Returns:
The TimeZone used by the JXMonthView.

setTimeZone

public void setTimeZone(TimeZone tz)
Sets the time zone with the given time zone value.

Parameters:
tz - The TimeZone.

isAntialiased

public boolean isAntialiased()
Returns true if anti-aliased text is enabled for this component, false otherwise.

Returns:
boolean true if anti-aliased text is enabled, false otherwise.

setAntialiased

public void setAntialiased(boolean antiAlias)
Turns on/off anti-aliased text for this component.

Parameters:
antiAlias - true for anti-aliased text, false to turn it off.

getSelectedBackground

public Color getSelectedBackground()
Returns the selected background color.

Returns:
the selected background color.

setSelectedBackground

public void setSelectedBackground(Color c)
Sets the selected background color to c. The default color is 138, 173, 209 (Blue-ish)

Parameters:
c - Selected background.

getTodayBackground

public Color getTodayBackground()
Returns the color used when painting the today background.

Returns:
Color Color

setTodayBackground

public void setTodayBackground(Color c)
Sets the color used to draw the bounding box around today. The default is the background of the JXMonthView component.

Parameters:
c - color to set

getMonthStringBackground

public Color getMonthStringBackground()
Returns the color used to paint the month string background.

Returns:
Color Color.

setMonthStringBackground

public void setMonthStringBackground(Color c)
Sets the color used to draw the background of the month string. The default is 138, 173, 209 (Blue-ish).

Parameters:
c - color to set

getMonthStringForeground

public Color getMonthStringForeground()
Returns the color used to paint the month string foreground.

Returns:
Color Color.

setMonthStringForeground

public void setMonthStringForeground(Color c)
Sets the color used to draw the foreground of the month string. The default is Color.WHITE.

Parameters:
c - color to set

setDaysOfTheWeekForeground

public void setDaysOfTheWeekForeground(Color c)
Sets the color used to draw the foreground of each day of the week. These are the titles

Parameters:
c - color to set

getDaysOfTheWeekForeground

public Color getDaysOfTheWeekForeground()
Returns:
Color Color

setDayForeground

public void setDayForeground(int dayOfWeek,
                             Color c)
Set the color to be used for painting the specified day of the week. Acceptable values are Calendar.SUNDAY - Calendar.SATURDAY.

Parameters:
dayOfWeek - constant value defining the day of the week.
c - The color to be used for painting the numeric day of the week.

getDayForeground

public Color getDayForeground(int dayOfWeek)
Return the color that should be used for painting the numerical day of the week.

Parameters:
dayOfWeek - The day of week to get the color for.
Returns:
The color to be used for painting the numeric day of the week. If this was no color has yet been defined the component foreground color will be returned.

setFlaggedDayForeground

public void setFlaggedDayForeground(Color c)
Set the color to be used for painting the foreground of a flagged day.

Parameters:
c - The color to be used for painting.

getFlaggedDayForeground

public Color getFlaggedDayForeground()
Return the color that should be used for painting the foreground of the flagged day.

Returns:
The color to be used for painting

getMonthStringInsets

public Insets getMonthStringInsets()
Returns a copy of the insets used to paint the month string background.

Returns:
Insets Month string insets.

setMonthStringInsets

public void setMonthStringInsets(Insets insets)
Insets used to modify the width/height when painting the background of the month string area.

Parameters:
insets - Insets

getPreferredCols

public int getPreferredCols()
Returns the preferred number of columns to paint calendars in.

Returns:
int Columns of calendars.

setPreferredCols

public void setPreferredCols(int cols)
The preferred number of columns to paint calendars.

Parameters:
cols - The number of columns of calendars.

getPreferredRows

public int getPreferredRows()
Returns the preferred number of rows to paint calendars in.

Returns:
int Rows of calendars.

setPreferredRows

public void setPreferredRows(int rows)
Sets the preferred number of rows to paint calendars.

Parameters:
rows - The number of rows of calendars.

setBounds

public void setBounds(Rectangle r)
Moves and resizes this component to conform to the new bounding rectangle r. This component's new position is specified by r.x and r.y, and its new size is specified by r.width and r.height

Overrides:
setBounds in class Component
Parameters:
r - The new bounding rectangle for this component
See Also:
Component.getBounds(), Component.setLocation(int, int), Component.setLocation(Point), Component.setSize(int, int), Component.setSize(Dimension)

setFont

public void setFont(Font font)
Sets the font of this component.

Overrides:
setFont in class JComponent
Parameters:
font - The font to become this component's font; if this parameter is null then this component will inherit the font of its parent.
See Also:
Component.getFont()

removeNotify

public void removeNotify()
Notifies this component that it no longer has a parent component. When this method is invoked, any KeyboardActions set up in the the chain of parent components are removed.

Overrides:
removeNotify in class JComponent
See Also:
JComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)

addNotify

public void addNotify()
Notifies this component that it now has a parent component. When this method is invoked, the chain of parent components is set up with KeyboardAction event listeners.

Overrides:
addNotify in class JComponent
See Also:
JComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)

getCalendar

public Calendar getCalendar()

getDayAt

public long getDayAt(int x,
                     int y)
Return a long representing the date at the specified x/y position. The date returned will have a valid day, month and year. Other fields such as hour, minute, second and milli-second will be set to 0.

Parameters:
x - X position
y - Y position
Returns:
long The date, -1 if position does not contain a date.

getActionCommand

public String getActionCommand()
Returns the string currently used to identiy fired ActionEvents.

Returns:
String The string used for identifying ActionEvents.

setActionCommand

public void setActionCommand(String actionCommand)
Sets the string used to identify fired ActionEvents.

Parameters:
actionCommand - The string used for identifying ActionEvents.

addActionListener

public void addActionListener(ActionListener l)
Adds an ActionListener.

The ActionListener will receive an ActionEvent when a selection has been made.

Parameters:
l - The ActionListener that is to be notified

removeActionListener

public void removeActionListener(ActionListener l)
Removes an ActionListener.

Parameters:
l - The action listener to remove.

getListeners

public <T extends EventListener> T[] getListeners(Class<T> listenerType)
Description copied from class: javax.swing.JComponent
Returns an array of all the objects currently registered as FooListeners upon this JComponent. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a JComponent c for its mouse listeners with the following code:

MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));
If no such listeners exist, this method returns an empty array.

Overrides:
getListeners in class JComponent
Parameters:
listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this component, or an empty array if no such listeners have been added
See Also:
JComponent.getVetoableChangeListeners(), JComponent.getAncestorListeners()

fireActionPerformed

protected void fireActionPerformed()
Fires an ActionEvent to all listeners.


postActionEvent

public void postActionEvent()

main

public static void main(String[] args)