Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdesktop.swingx
Class JXMonthView

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  org.jdesktop.swingx.JXMonthView

All Implemented Interfaces:
  java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

    public class JXMonthView

extends javax.swing.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);

        monthView.setFlaggedDates(cal1.getTime(), cal2.getTime(), new Date());

Applications may have the need to allow users to select different ranges of dates. There are three modes of selection that are supported, single, single interval and multiple interval selection. Once a selection is made a DateSelectionEvent is fired to inform listeners of the change.

        // Change the selection mode to select full weeks.
        monthView.setSelectionMode(SelectionMode.SINGLE_INTERVAL_SELECTION);

        // Register a date selection listener to get notified about
        // any changes in the date selection model.
        monthView.getSelectionModel().addDateSelectionListener(new DateSelectionListener {
            public void valueChanged(DateSelectionEvent e) {
                log.info(e.getSelection());
            }
        });

NOTE (for users of earlier versions): as of version 1.19 control about selection dates is moved completely into the model. The default model used is of type DaySelectionModel, which handles dates in the same way the JXMonthView did earlier (that is, normalize all to the start of the day, which means zeroing all time fields).

Version:
  $Revision: 3689 $
Author:
  Joshua Outwater, Jeanette Winzenburg
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class javax.swing.JComponent
`javax.swing.JComponent.AccessibleJComponent`

Nested classes/interfaces inherited from class java.awt.Container
`java.awt.Container.AccessibleAWTContainer`

Nested classes/interfaces inherited from class java.awt.Component
`java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

Field Summary
`protected java.awt.Insets` | `_monthStringInsets`
`static java.lang.String` | `BOX_PADDING_X`
`static java.lang.String` | `BOX_PADDING_Y`
`static java.lang.String` | `CANCEL_KEY` action command used for cancel actionEvent.
`static java.lang.String` | `COMMIT_KEY` action command used for commit actionEvent.
`static int` | `DAYS_IN_WEEK`
`static java.lang.String` | `DAYS_OF_THE_WEEK`
`static java.lang.String` | `FLAGGED_DATES`
`protected java.util.Date` | `modifiedEndDate`
`protected java.util.Date` | `modifiedStartDate`
`static int` | `MONTHS_IN_YEAR`
`static java.lang.String` | `SELECTION_MODEL`
`static java.lang.String` | `TRAVERSABLE`
`static java.lang.String` | `uiClassID` UI Class ID

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 default Locale and the current system time as the first date to display.
`JXMonthView(java.util.Date firstDisplayedDay)` Create a new instance of the `JXMonthView` class using the default Locale and the given time as the first date to display.
`JXMonthView(java.util.Date firstDisplayedDay, DateSelectionModel model)` Create a new instance of the `JXMonthView` class using the default Locale, the given time as the first date to display and the given selection model.
`JXMonthView(java.util.Date firstDisplayedDay, DateSelectionModel model, java.util.Locale locale)` Create a new instance of the `JXMonthView` class using the given Locale, the given time as the first date to display and the given selection model.
`JXMonthView(java.util.Locale locale)` Create a new instance of the `JXMonthView` class using the default Locale and the current system time as the first date to display.

Method Summary
`void` | `addActionListener(java.awt.event.ActionListener l)` Adds an ActionListener.
`void` | `addFlaggedDates(java.util.Date... flagged)` Adds the dates to the flags.
`void` | `addNotify()`
`void` | `addSelectionInterval(java.util.Date startDate, java.util.Date endDate)` Adds the selection interval to the selection model.
`void` | `cancelSelection()` Cancels the selection.
`protected void` | `cleanupWeekSelectionDates(java.util.Date startDate, java.util.Date endDate)` Deprecated. pre-0.9.5 - this is kept as a reminder only, don't use! we can make this private or comment it out after next version
`void` | `clearFlaggedDates()` Clears all flagged dates.
`void` | `clearSelection()` Clear any selection from the selection model
`void` | `commitSelection()` Commits the current selection.
`void` | `ensureDateVisible(java.util.Date date)` Moves the `date` into the visible region of the calendar.
`protected void` | `fireActionPerformed(java.lang.String actionCommand)` Creates and fires an ActionEvent with the given action command to all listeners.
`protected java.util.Date` | `getAnchorDate()` Returns the anchor date.
`int` | `getBoxPaddingX()` Returns the padding used between days in the calendar.
`int` | `getBoxPaddingY()` Returns the padding used above and below days in the calendar.
`java.util.Calendar` | `getCalendar()` Returns a clone of the internal calendar, with it's time set to firstDisplayedDate.
`java.util.Date` | `getDayAtLocation(int x, int y)` Returns the Date at the given location.
`java.awt.Color` | `getDayForeground(int dayOfWeek)` Return the color that should be used for painting the numerical day of the week.
`java.lang.String` | `getDayOfTheWeek(int dayOfWeek)`
`java.lang.String[]` | `getDaysOfTheWeek()` Returns the String representation for each day of the week.
`java.awt.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.
`java.util.Date` | `getFirstDisplayedDay()` Returns the first displayed date.
`java.util.Date` | `getFirstSelectionDate()` Returns the earliest selected date.
`java.util.SortedSet<java.util.Date>` | `getFlaggedDates()` Returns a sorted set of flagged Dates.
`java.awt.Color` | `getFlaggedDayForeground()` Return the color that should be used for painting the foreground of the flagged day.
`java.util.Date` | `getLastDisplayedDay()` Returns the last date able to be displayed.
`java.util.Date` | `getLastSelectionDate()` Returns the earliest selected date.
`
`<T extends java.util.EventListener> T[]`
` | `getListeners(java.lang.Class<T> listenerType)`
`java.util.Date` | `getLowerBound()` Return the lower bound date that is allowed to be selected for this model.
`java.awt.Color` | `getMonthStringBackground()` Returns the color used to paint the month string background.
`java.awt.Color` | `getMonthStringForeground()` Returns the color used to paint the month string foreground.
`java.awt.Insets` | `getMonthStringInsets()` Returns a copy of the insets used to paint the month string background.
`java.awt.Color` | `getPerDayOfWeekForeground(int dayOfWeek)` Return the color that should be used for painting the numerical day of the week.
`int` | `getPreferredColumnCount()` Returns the preferred number of columns to paint calendars in.
`int` | `getPreferredRowCount()` Returns the preferred number of rows to paint calendars in.
`java.util.SortedSet<java.util.Date>` | `getSelection()` Get the current selection
`java.awt.Color` | `getSelectionBackground()` Returns the selected background color.
`java.util.Date` | `getSelectionDate()` Returns the earliest selected date.
`java.awt.Color` | `getSelectionForeground()` Returns the selected foreground color.
`DateSelectionModel.SelectionMode` | `getSelectionMode()` Returns the current selection mode for this JXMonthView.
`DateSelectionModel` | `getSelectionModel()` Returns the date selection model which drives this JXMonthView.
`java.util.TimeZone` | `getTimeZone()` Gets the time zone.
`java.util.Date` | `getToday()` Returns the start of today in this monthviews calendar coordinates.
`java.awt.Color` | `getTodayBackground()` Returns the color used when painting the today background.
`MonthViewUI` | `getUI()`
`java.lang.String` | `getUIClassID()`
`java.util.Date` | `getUpperBound()` Return the upper bound date that is allowed to be selected for this model.
`boolean` | `hasFlaggedDates()` Returns a boolean indicating if this monthView has flagged dates.
`protected void` | `incrementToday()` Increments today.
`boolean` | `isComponentInputMapEnabled()` Returns the componentInputMapEnabled property.
`boolean` | `isFlaggedDate(java.util.Date date)` Identifies whether or not the date passed is a flagged date.
`boolean` | `isSelected(java.util.Date date)` Returns true if the specified date falls within the _startSelectedDate and _endSelectedDate range.
`boolean` | `isSelectionEmpty()` Return true if the selection is empty, false otherwise
`boolean` | `isShowingLeadingDays()` Returns a boolean indicating whether or not we're showing leading dates.
`boolean` | `isShowingTrailingDays()` Returns a boolean indicating 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(java.util.Date date)` Identifies whether or not the date passed is an unselectable date.
`boolean` | `isZoomable()` Returns true if zoomable (through date ranges).
`void` | `removeActionListener(java.awt.event.ActionListener l)` Removes an ActionListener.
`void` | `removeFlaggedDates(java.util.Date... flagged)` Unflags the given dates.
`void` | `removeNotify()`
`void` | `removeSelectionInterval(java.util.Date startDate, java.util.Date endDate)` Removes the selection interval from the selection model.
`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` | `setComponentInputMapEnabled(boolean enabled)` Sets the component input map enablement property.
`void` | `setDayForeground(int dayOfWeek, java.awt.Color c)` Set the color to be used for painting the specified day of the week.
`void` | `setDaysOfTheWeek(java.lang.String[] days)` Sets the String representation for each day of the week as used in the header of the day's grid.
`void` | `setDaysOfTheWeekForeground(java.awt.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` | `setFirstDisplayedDay(java.util.Date date)` Set the first displayed date.
`void` | `setFlaggedDates(java.util.Date... flagged)` Replace all flags with the given dates.
`void` | `setFlaggedDayForeground(java.awt.Color c)` Set the color to be used for painting the foreground of a flagged day.
`void` | `setLocale(java.util.Locale locale)` Sets locale and resets text and format used to display months and days.
`void` | `setLowerBound(java.util.Date lowerBound)` Set the lower bound date that is allowed to be selected.
`void` | `setMonthStringBackground(java.awt.Color c)` Sets the color used to draw the background of the month string.
`void` | `setMonthStringForeground(java.awt.Color c)` Sets the color used to draw the foreground of the month string.
`void` | `setMonthStringInsets(java.awt.Insets insets)` Insets used to modify the width/height when painting the background of the month string area.
`void` | `setPreferredColumnCount(int cols)` Sets the preferred number of columns of calendars.
`void` | `setPreferredRowCount(int rows)` Sets the preferred number of rows to paint calendars.Does nothing if rows <= 0.
`void` | `setSelectionBackground(java.awt.Color c)` Sets the selected background color to `c`.
`void` | `setSelectionDate(java.util.Date newDate)` Sets the model's selection to the given date or clears the selection if null.
`void` | `setSelectionForeground(java.awt.Color c)` Sets the selected foreground color to `c`.
`void` | `setSelectionInterval(java.util.Date startDate, java.util.Date endDate)` Sets the selection interval to the selection model.
`void` | `setSelectionMode(DateSelectionModel.SelectionMode selectionMode)` Set the selection mode for this JXMonthView.
`void` | `setSelectionModel(DateSelectionModel model)` Sets the date selection model to drive this monthView.
`void` | `setShowingLeadingDays(boolean value)` Sets a boolean property indicating whether or not to show leading dates for a months displayed by this component.
`void` | `setShowingTrailingDays(boolean value)` Sets a boolean property indicating whether or not to show trailing dates for the months displayed by this component.
`void` | `setShowingWeekNumber(boolean showWeekNumber)` Set whether or not this `JXMonthView` will display week numbers or not.
`void` | `setTimeZone(java.util.TimeZone tz)` Sets the time zone with the given time zone value.
`protected void` | `setToday(java.util.Date date)` Sets the date which represents today.
`void` | `setTodayBackground(java.awt.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(java.util.Date... unselectableDates)` Sets the dates that should be unselectable.
`void` | `setUpperBound(java.util.Date upperBound)` Set the upper bound date that is allowed to be selected.
`void` | `setZoomable(boolean zoomable)` Sets the zoomable property.
`protected void` | `updateDatesAfterTimeZoneChange(java.util.TimeZone oldTimeZone)` All dates are "cleaned" relative to the timezone they had been set.
`protected void` | `updateTodayFromCurrentTime()` Sets today from the current system time.
`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, getBaseline, getBaselineResizeBehavior, 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, isPaintingForPrint, 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, setFont, 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, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, 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

### COMMIT_KEY

    public static final java.lang.String COMMIT_KEY

  action command used for commit actionEvent.

  See Also:
    Constant Field Values

### CANCEL_KEY

    public static final java.lang.String CANCEL_KEY

  action command used for cancel actionEvent.

  See Also:
    Constant Field Values

### BOX_PADDING_X

    public static final java.lang.String BOX_PADDING_X

See Also:
  Constant Field Values

### BOX_PADDING_Y

    public static final java.lang.String BOX_PADDING_Y

See Also:
  Constant Field Values

### DAYS_OF_THE_WEEK

    public static final java.lang.String DAYS_OF_THE_WEEK

See Also:
  Constant Field Values

### SELECTION_MODEL

    public static final java.lang.String SELECTION_MODEL

See Also:
  Constant Field Values

### TRAVERSABLE

    public static final java.lang.String TRAVERSABLE

See Also:
  Constant Field Values

### FLAGGED_DATES

    public static final java.lang.String FLAGGED_DATES

See Also:
  Constant Field Values

### uiClassID

    public static final java.lang.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

### modifiedStartDate

    protected java.util.Date modifiedStartDate

### modifiedEndDate

    protected java.util.Date modifiedEndDate

### _monthStringInsets

    protected java.awt.Insets _monthStringInsets

Constructor Detail

### JXMonthView

    public JXMonthView()

  Create a new instance of the `JXMonthView` class using the default Locale and the current system time as the first date to display.

### JXMonthView

    public JXMonthView(java.util.Locale locale)

  Create a new instance of the `JXMonthView` class using the default Locale and the current system time as the first date to display.

  Parameters:
    `locale` - desired locale, if null the system default locale is used

### JXMonthView

    public JXMonthView(java.util.Date firstDisplayedDay)

  Create a new instance of the `JXMonthView` class using the default Locale and the given time as the first date to display.

  Parameters:
    `firstDisplayedDay` - a day of the first month to display; if null, the current System time is used.

### JXMonthView

    public JXMonthView(java.util.Date firstDisplayedDay,
                       DateSelectionModel model)

  Create a new instance of the `JXMonthView` class using the default Locale, the given time as the first date to display and the given selection model.

  Parameters:
    `firstDisplayedDay` - a day of the first month to display; if null, the current System time is used.
    `model` - the selection model to use, if null a `DefaultSelectionModel` is created.

### JXMonthView

    public JXMonthView(java.util.Date firstDisplayedDay,
                       DateSelectionModel model,
                       java.util.Locale locale)

  Create a new instance of the `JXMonthView` class using the given Locale, the given time as the first date to display and the given selection model.

  Parameters:
    `firstDisplayedDay` - a day of the first month to display; if null, the current System time is used.
    `model` - the selection model to use, if null a `DefaultSelectionModel` is created.
    `locale` - desired locale, if null the system default locale is used

Method Detail

### setLocale

    public void setLocale(java.util.Locale locale)

  Sets locale and resets text and format used to display months and days. Also resets firstDayOfWeek.

  PENDING JW: the following warning should be obsolete (installCalendar should take care) - check if it really is!

  Warning: Since this resets any string labels that are cached in UI (month and day names) and firstDayofWeek, use `setDaysOfTheWeek` and/or setFirstDayOfWeek after (re)setting locale.

  Overrides:
    `setLocale` in class `java.awt.Component`
  Parameters:
    `locale` - new Locale to be used for formatting
  See Also:
    `setDaysOfTheWeek(String[])`, `setFirstDayOfWeek(int)`

### getCalendar

    public java.util.Calendar getCalendar()

  Returns a clone of the internal calendar, with it's time set to firstDisplayedDate. PENDING: firstDisplayed useful as reference time? It's timezone dependent anyway. Think: could return with monthView's today instead?

  Returns:
    a clone of internal calendar, configured to the current firstDisplayedDate
  Throws:
    `java.lang.IllegalStateException` - if called before instantitation is completed

### getTimeZone

    public java.util.TimeZone getTimeZone()

  Gets the time zone.

  Returns:
    The `TimeZone` used by the `JXMonthView`.

### setTimeZone

    public void setTimeZone(java.util.TimeZone tz)

  Sets the time zone with the given time zone value. This is a bound property.

  Parameters:
    `tz` - The `TimeZone`.

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

### getAnchorDate

    protected java.util.Date getAnchorDate()

  Returns the anchor date. Currently, this is the "uncleaned" input date of setFirstDisplayedDate. This is a quick hack for Issue #618-swingx, to have some invariant for testing. Do not use in client code, may change without notice!

  Returns:
    the "uncleaned" first display date or null if the firstDisplayedDay is not yet set.

### updateDatesAfterTimeZoneChange

    protected void updateDatesAfterTimeZoneChange(java.util.TimeZone oldTimeZone)

  All dates are "cleaned" relative to the timezone they had been set. After changing the timezone, they need to be updated to the new. Here: clear everything.

  Parameters:
    `oldTimeZone` - the timezone before the change

### getLastDisplayedDay

    public java.util.Date getLastDisplayedDay()

  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.

### getFirstDisplayedDay

    public java.util.Date getFirstDisplayedDay()

  Returns the first displayed date.

  Returns:
    long The first displayed date.

### setFirstDisplayedDay

    public void setFirstDisplayedDay(java.util.Date 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.

### ensureDateVisible

    public void ensureDateVisible(java.util.Date 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.

  NOTE: this is the recommended method to scroll to a particular date, the functionally equivalent method taking a long as parameter will most probably be deprecated.

  Parameters:
    `date` - Date to make visible, must not be null.
  See Also:
    `ensureDateVisible(Date)`

### getDayAtLocation

    public java.util.Date getDayAtLocation(int x,
                                           int y)

  Returns the Date at the given location. May be null if the coordinates don't map to a day in the month which contains the coordinates. Specifically: hitting leading/trailing dates returns null. Mapping pixel to calendar day.

  Parameters:
    `x` - the x position of the location in pixel
    `y` - the y position of the location in pixel
  Returns:
    the day at the given location or null if the location doesn't map to a day in the month which contains the coordinates.

### updateTodayFromCurrentTime

    protected void updateTodayFromCurrentTime()

  Sets today from the current system time. temporary widened access for testing.

### incrementToday

    protected void incrementToday()

  Increments today. This is used by the timer. PENDING: is it safe? doesn't check if we are really tomorrow? temporary widened access for testing.

### setToday

    protected void setToday(java.util.Date date)

  Sets the date which represents today. Internally modified to the start of the day which contains the given date in this monthView's calendar coordinates. temporary widened access for testing.

  Parameters:
    `date` - the date which should be used as today.

### getToday

    public java.util.Date getToday()

  Returns the start of today in this monthviews calendar coordinates.

  Returns:
    the start of today as Date.

### 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 `javax.swing.JComponent`
  See Also:
    `UIManager.getUI(JComponent)`

### getUIClassID

    public java.lang.String getUIClassID()

  Overrides:
    `getUIClassID` in class `javax.swing.JComponent`

### getSelectionModel

    public DateSelectionModel getSelectionModel()

  Returns the date selection model which drives this JXMonthView.

  Returns:
    the date selection model

### setSelectionModel

    public void setSelectionModel(DateSelectionModel model)

  Sets the date selection model to drive this monthView.

  Parameters:
    `model` - the selection model to use, must not be null.
  Throws:
    `java.lang.NullPointerException` - if model is null

### clearSelection

    public void clearSelection()

  Clear any selection from the selection model

### isSelectionEmpty

    public boolean isSelectionEmpty()

  Return true if the selection is empty, false otherwise

  Returns:
    true if the selection is empty, false otherwise

### getSelection

    public java.util.SortedSet<java.util.Date> getSelection()

  Get the current selection

  Returns:
    sorted set of selected dates

### addSelectionInterval

    public void addSelectionInterval(java.util.Date startDate,
                                     java.util.Date endDate)

  Adds the selection interval 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(java.util.Date startDate,
                                     java.util.Date endDate)

  Sets the selection interval 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(java.util.Date startDate,
                                        java.util.Date endDate)

  Removes the selection interval from 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

### getSelectionMode

    public DateSelectionModel.SelectionMode getSelectionMode()

  Returns the current selection mode for this JXMonthView.

  Returns:
    int Selection mode.

### setSelectionMode

    public void setSelectionMode(DateSelectionModel.SelectionMode selectionMode)

  Set the selection mode for this JXMonthView.

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

### getFirstSelectionDate

    public java.util.Date getFirstSelectionDate()

  Returns the earliest selected date.

  Returns:
    the first Date in the selection or null if empty.

### getLastSelectionDate

    public java.util.Date getLastSelectionDate()

  Returns the earliest selected date.

  Returns:
    the first Date in the selection or null if empty.

### getSelectionDate

    public java.util.Date getSelectionDate()

  Returns the earliest selected date. PENDING JW: keep this? it was introduced before the first/last in model. When delegating everything, we duplicate here.

  Returns:
    the first Date in the selection or null if empty.

### setSelectionDate

    public void setSelectionDate(java.util.Date newDate)

  Sets the model's selection to the given date or clears the selection if null.

  Parameters:
    `newDate` - the selection date to set

### isSelected

    public boolean isSelected(java.util.Date date)

  Returns true if the specified date falls within the _startSelectedDate and _endSelectedDate range.

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

### setLowerBound

    public void setLowerBound(java.util.Date lowerBound)

  Set the lower bound date that is allowed to be selected.

  Parameters:
    `lowerBound` - the lower bound, null means none.

### setUpperBound

    public void setUpperBound(java.util.Date upperBound)

  Set the upper bound date that is allowed to be selected.

  Parameters:
    `upperBound` - the upper bound, null means none.

### getLowerBound

    public java.util.Date getLowerBound()

  Return the lower bound date that is allowed to be selected for this model.

  Returns:
    lower bound date or null if not set

### getUpperBound

    public java.util.Date getUpperBound()

  Return the upper bound date that is allowed to be selected for this model.

  Returns:
    upper bound date or null if not set

### isUnselectableDate

    public boolean isUnselectableDate(java.util.Date date)

  Identifies whether or not the date passed is an unselectable date.

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

### setUnselectableDates

    public void setUnselectableDates(java.util.Date... unselectableDates)

  Sets the dates that should be unselectable. This will replace the model's current set of unselectable dates. The implication is that calling with zero dates will remove all unselectable dates.

  NOTE: neither the given array nor any of its elements must be null.

  Parameters:
    `unselectableDates` - zero or more not-null dates that should be unselectable.
  Throws:
    `java.lang.NullPointerException` - if either the array or any of the elements are null

### isFlaggedDate

    public boolean isFlaggedDate(java.util.Date date)

  Identifies whether or not the date passed is a flagged date.

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

### setFlaggedDates

    public void setFlaggedDates(java.util.Date... flagged)

  Replace all flags with the given dates.

  NOTE: neither the given array nor any of its elements should be null. Currently, a null array will be tolerated to ease migration. A null has the same effect as clearFlaggedDates.

  Parameters:
    `flagged` - the dates to be flagged

### addFlaggedDates

    public void addFlaggedDates(java.util.Date... flagged)

  Adds the dates to the flags. NOTE: neither the given array nor any of its elements should be null. Currently, a null array will be tolerated to ease migration. A null does nothing.

  Parameters:
    `flagged` - the dates to be flagged

### removeFlaggedDates

    public void removeFlaggedDates(java.util.Date... flagged)

  Unflags the given dates. NOTE: neither the given array nor any of its elements should be null. Currently, a null array will be tolerated to ease migration.

  Parameters:
    `flagged` - the dates to be unflagged

### clearFlaggedDates

    public void clearFlaggedDates()

  Clears all flagged dates.

### getFlaggedDates

    public java.util.SortedSet<java.util.Date> getFlaggedDates()

  Returns a sorted set of flagged Dates. The returned set is guaranteed to be not null, but may be empty.

  Returns:
    a sorted set of flagged dates.

### hasFlaggedDates

    public boolean hasFlaggedDates()

  Returns a boolean indicating if this monthView has flagged dates.

  Returns:
    a boolean indicating if this monthView has flagged dates.

### setShowingLeadingDays

    public void setShowingLeadingDays(boolean value)

  Sets a boolean property indicating whether or not to show leading dates for a months displayed by this component.

  The default value is false.

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

### isShowingLeadingDays

    public boolean isShowingLeadingDays()

  Returns a boolean indicating whether or not we're showing leading dates.

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

### setShowingTrailingDays

    public void setShowingTrailingDays(boolean value)

  Sets a boolean property indicating whether or not to show trailing dates for the months displayed by this component.

  The default value is false.

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

### isShowingTrailingDays

    public boolean isShowingTrailingDays()

  Returns a boolean indicating whether or not we're showing trailing dates.

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

### isTraversable

    public boolean isTraversable()

  Returns whether or not the month view supports traversing months. If zoomable is enabled, traversable is enabled as well. Otherwise returns the traversable property as set by client code.

  Returns:
    `true` if month traversing is enabled.
  See Also:
    `setZoomable(boolean)`

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

  The default value is false.

  PENDING JW: fire the "real" property or the compound with zoomable?

  Parameters:
    `traversable` - set to true to enable month traversing, false otherwise.
  See Also:
    `isTraversable()`, `setZoomable(boolean)`

### isZoomable

    public boolean isZoomable()

  Returns true if zoomable (through date ranges).

  Returns:
    true if zoomable is enabled.
  See Also:
    `setZoomable(boolean)`

### setZoomable

    public void setZoomable(boolean zoomable)

  Sets the zoomable property. If true, the calendar's date range can be zoomed. This state implies that the calendar is traversable and showing exactly one calendar box, effectively ignoring the properties.

  Note: The actual zoomable behaviour is not yet implemented.

  Parameters:
    `zoomable` - a boolean indicating whether or not zooming date ranges is enabled.
  See Also:
    `setTraversable(boolean)`

### 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(java.lang.String[] days)

  Sets the String representation for each day of the week as used in the header of the day's grid. For this method the first days of the week days[0] is assumed to be `Calendar.SUNDAY`. If null, the representation provided by the MonthViewUI is used. The default value is the representation as returned from the MonthViewUI.

  Parameters:
    `days` - Array of characters that represents each day
  Throws:
    `java.lang.IllegalArgumentException` - if not null and `days.length` != DAYS_IN_WEEK

### getDaysOfTheWeek

    public java.lang.String[] getDaysOfTheWeek()

  Returns the String representation for each day of the week.

  Returns:
    String representation for the days of the week, guaranteed to never be null.
  See Also:
    `setDaysOfTheWeek(String[])`, `MonthViewUI`

### getDayOfTheWeek

    public java.lang.String getDayOfTheWeek(int dayOfWeek)

  Parameters:
    `dayOfWeek` -
  Returns:
    String representation of day of week.

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

### getSelectionBackground

    public java.awt.Color getSelectionBackground()

  Returns the selected background color.

  Returns:
    the selected background color.

### setSelectionBackground

    public void setSelectionBackground(java.awt.Color c)

  Sets the selected background color to `c`. The default color is installed by the ui.

  Parameters:
    `c` - Selected background.

### getSelectionForeground

    public java.awt.Color getSelectionForeground()

  Returns the selected foreground color.

  Returns:
    the selected foreground color.

### setSelectionForeground

    public void setSelectionForeground(java.awt.Color c)

  Sets the selected foreground color to `c`. The default color is installed by the ui.

  Parameters:
    `c` - Selected foreground.

### getTodayBackground

    public java.awt.Color getTodayBackground()

  Returns the color used when painting the today background.

  Returns:
    Color Color

### setTodayBackground

    public void setTodayBackground(java.awt.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 java.awt.Color getMonthStringBackground()

  Returns the color used to paint the month string background.

  Returns:
    Color Color.

### setMonthStringBackground

    public void setMonthStringBackground(java.awt.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 java.awt.Color getMonthStringForeground()

  Returns the color used to paint the month string foreground.

  Returns:
    Color Color.

### setMonthStringForeground

    public void setMonthStringForeground(java.awt.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(java.awt.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 java.awt.Color getDaysOfTheWeekForeground()

  Returns:
    Color Color

### setDayForeground

    public void setDayForeground(int dayOfWeek,
                                 java.awt.Color c)

  Set the color to be used for painting the specified day of the week. Acceptable values are Calendar.SUNDAY - Calendar.SATURDAY.

  PENDING JW: this is not a property - should it be and fire a change notification? If so, how?

  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 java.awt.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.

### getPerDayOfWeekForeground

    public java.awt.Color getPerDayOfWeekForeground(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 or null If no color has yet been defined.

### setFlaggedDayForeground

    public void setFlaggedDayForeground(java.awt.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 java.awt.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 java.awt.Insets getMonthStringInsets()

  Returns a copy of the insets used to paint the month string background.

  Returns:
    Insets Month string insets.

### setMonthStringInsets

    public void setMonthStringInsets(java.awt.Insets insets)

  Insets used to modify the width/height when painting the background of the month string area.

  Parameters:
    `insets` - Insets

### getPreferredColumnCount

    public int getPreferredColumnCount()

  Returns the preferred number of columns to paint calendars in.

  Returns:
    int preferred number of columns of calendars.
  See Also:
    `setPreferredColumnCount(int)`

### setPreferredColumnCount

    public void setPreferredColumnCount(int cols)

  Sets the preferred number of columns of calendars. Does nothing if cols <= 0. The default value is 1.

  Parameters:
    `cols` - The number of columns of calendars.
  See Also:
    `getPreferredColumnCount()`

### getPreferredRowCount

    public int getPreferredRowCount()

  Returns the preferred number of rows to paint calendars in.

  Returns:
    int Rows of calendars.
  See Also:
    `setPreferredRowCount(int)`

### setPreferredRowCount

    public void setPreferredRowCount(int rows)

  Sets the preferred number of rows to paint calendars.Does nothing if rows <= 0. The default value is 1.

  Parameters:
    `rows` - The number of rows of calendars.
  See Also:
    `getPreferredRowCount()`

### removeNotify

    public void removeNotify()

  Overrides:
    `removeNotify` in class `javax.swing.JComponent`

### addNotify

    public void addNotify()

  Overrides:
    `addNotify` in class `javax.swing.JComponent`

### commitSelection

    public void commitSelection()

  Commits the current selection.

  Resets the model's adjusting property to false and fires an ActionEvent with the COMMIT_KEY action command.

  See Also:
    `cancelSelection()`, `DateSelectionModel.setAdjusting(boolean)`

### cancelSelection

    public void cancelSelection()

  Cancels the selection.

  Resets the model's adjusting property to false and fires an ActionEvent with the CANCEL_KEY action command.

  See Also:
    `commitSelection()`, `DateSelectionModel.setAdjusting(boolean)`

### setComponentInputMapEnabled

    public void setComponentInputMapEnabled(boolean enabled)

  Sets the component input map enablement property.

  If enabled, the keybinding for WHEN_IN_FOCUSED_WINDOW are installed, otherwise not. Changing this property will install/clear the corresponding key bindings. Typically, clients which want to use the monthview in a popup, should enable these.

  The default value is false.

  Parameters:
    `enabled` - boolean to indicate whether the component input map should be enabled.
  See Also:
    `isComponentInputMapEnabled()`

### isComponentInputMapEnabled

    public boolean isComponentInputMapEnabled()

  Returns the componentInputMapEnabled property.

  Returns:
    a boolean indicating whether the component input map is enabled.
  See Also:
    `setComponentInputMapEnabled(boolean)`

### addActionListener

    public void addActionListener(java.awt.event.ActionListener l)

  Adds an ActionListener.

  The ActionListener will receive an ActionEvent with its actionCommand set to COMMIT_KEY or CANCEL_KEY after the selection has been committed or canceled, respectively.

  Note that actionEvents are typically fired after a dedicated user gesture to end an ongoing selectin (like ENTER, ESCAPE) or after explicit programmatic commits/cancels. It is usually not fired after each change to the selection state. Client code which wants to be notified about all selection changes should register a DateSelectionListener to the DateSelectionModel.

  Parameters:
    `l` - The ActionListener that is to be notified
  See Also:
    `commitSelection()`, `cancelSelection()`, `getSelectionModel()`

### removeActionListener

    public void removeActionListener(java.awt.event.ActionListener l)

  Removes an ActionListener.

  Parameters:
    `l` - The ActionListener to remove.

### getListeners

    public <T extends java.util.EventListener> T[] getListeners(java.lang.Class<T> listenerType)

  Overrides:
    `getListeners` in class `javax.swing.JComponent`

### fireActionPerformed

    protected void fireActionPerformed(java.lang.String actionCommand)

  Creates and fires an ActionEvent with the given action command to all listeners.

  Parameters:
    `actionCommand` - the command for the created.

### cleanupWeekSelectionDates

    @Deprecated
    protected void cleanupWeekSelectionDates(java.util.Date startDate,
                                                        java.util.Date endDate)

  Deprecated. pre-0.9.5 - this is kept as a reminder only, don't use! we can make this private or comment it out after next version

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010. All Rights Reserved.