Java Date Picker v3.2

com.standbysoft.component.date.swing
Class JMonth

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.standbysoft.component.date.swing.JDateComponent
                  extended bycom.standbysoft.component.date.swing.JMonth
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
JMonthView

public class JMonth
extends JDateComponent

A JMonth is a convenient way of representing all the days of a month from the calendar. It inherits from JDateComponent which means that it uses a date selection model to restrict date selection as you need.

Although date selection can be controled using the selection model, the API has a few methods for the most frequent operations. It adds a method for selecting a set of dates and one for changing the selection type.

An important part of its API is reserved for customizing its appearance. You can control:

The third and last part of the API is dedicated to the MonthModel and its wrapper methods that define month specific information. The month model is a way of abstracting all the information about the currently displayed month, like:

Because this component is only a visualization for one calendar month, you might actually want to use the more feature rich JMonthView.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.standbysoft.component.date.swing.JDateComponent
JDateComponent.DateAction, JDateComponent.RollDateAction, JDateComponent.SelectFirstDayAction, JDateComponent.SelectLastDayAction, JDateComponent.SelectNoneAction, JDateComponent.SelectTodayAction
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String DATE_COMMAND
          Action name that indicates a date command.
protected  java.awt.Color gridColor
           
protected  boolean horizontalLinesVisible
           
protected  java.awt.Color monthBackground
           
protected  MonthModel monthModel
           
protected  MonthModelListener monthModelListener
          Listener that takes month model events from the model and fires them further away as events generated by this component.
protected  DateRenderer renderer
          Renderer that is used to display the dates of a month.
protected  java.awt.Color titleBackground
           
protected  java.awt.Color titleForeground
           
protected  java.awt.Color trailingForeground
           
protected  boolean verticalLinesVisible
           
protected  boolean weekNamesVisible
           
protected  boolean weekNumbersVisible
           
 
Fields inherited from class com.standbysoft.component.date.swing.JDateComponent
actionCommand, dateSelectionModel, dateSelectionModelListener, locale, selectFirstDayAction, selectLastDayAction, selectNextDayAction, selectNoneAction, selectPreviousDayAction, selectSameDayNextMonthAction, selectSameDayNextWeekAction, selectSameDayNextYearAction, selectSameDayPreviousMonthAction, selectSameDayPreviousWeekAction, selectSameDayPreviousYearAction, selectTodayAction
 
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
JMonth()
          Creates a component that displays the days of a month.
JMonth(MonthModel model)
           
JMonth(MonthModel model, DateSelectionModel dateSelectionModel)
           
 
Method Summary
 void addMonthModelListener(MonthModelListener listener)
          Registers a month model listener that will receive notifications when the month model model changes.
protected  void fireDowFirstChanged(MonthModelEvent evt)
           
protected  void fireDowNamesFormatChanged(MonthModelEvent evt)
           
protected  void fireMonthChanged(MonthModelEvent evt)
           
protected  void fireMonthNamesFormatChanged(MonthModelEvent evt)
           
 DateRenderer getDateRenderer()
          Returns the renderer used to display the dates of the month.
 int getDowFirst()
          Returns the first day of week.
 java.awt.Color getGridColor()
          Detrmines the color used to paint the grid.
 int getMonth()
          Returns the month displayed by this component.
 java.awt.Color getMonthBackground()
          Returns the background color for the displayed month.
 MonthModel getMonthModel()
          Returns the month model used by this component.
 java.util.Date[] getSelectedDates()
          Returns the selected dates.
 DateSelectionModel.SelectionMode getSelectionMode()
          Returns the selection mode used by this component.
 java.awt.Color getTitleBackground()
          Returns the background color for the month title.
 java.awt.Color getTitleForeground()
          Returns the foreground color for the month title.
 java.awt.Color getTrailingForeground()
          Returns the foreground color for trailing days.
 java.lang.String getUIClassID()
          Returns the name of the L&F class that renders this component.
 int getYear()
          Returns the year that is displayed by this component.
 boolean isHorizontalLinesVisible()
          Determines whether the horizontal lines of the grid are visible.
 boolean isVerticalLinesVisible()
          Determines whether the vertical lines of the grid are visible.
 boolean isWeekNamesVisible()
          Determines whether the week names are visible or not.
 boolean isWeekNumbersVisible()
          Determines whether the week numbers are visible or not.
 void removeMonthModelListener(MonthModelListener listener)
          Removes a specified month model listener.
 void requestFocus()
           
 void setDateRenderer(DateRenderer renderer)
          Specify a renderer that will be used to display the dates of the month.
 void setDowFirst(int dow)
          Specifies the first day of week.
 void setGridColor(java.awt.Color color)
          Specifies the color used to paint the grid when it is visible.
 void setHorizontalLinesVisible(boolean visible)
          Specifies whether the horizontal lines of the grid are visible.
 void setLocale(java.util.Locale locale)
          Specifies a new locale to be used by this component.
 void setMonth(int month)
          Specifies the month that is displayed by this component.
 void setMonthBackground(java.awt.Color color)
          Sets the background color for the displayed month.
 void setMonthModel(MonthModel model)
          Specifies a new month model for this component.
 void setSelectedDates(java.util.Date[] dates)
          Specifies the dates selected by this component.
 void setSelectionMode(DateSelectionModel.SelectionMode mode)
          Specifies a new selection mode to be used by this component.
 void setTitleBackground(java.awt.Color color)
          Sets the background color for the month title.
 void setTitleForeground(java.awt.Color color)
          Sets the foreground color for the month title.
 void setTrailingForeground(java.awt.Color color)
          Sets the foreground color for trailing days.
 void setVerticalLinesVisible(boolean visible)
          Specifies whether the vertical lines of the grid are visible.
 void setWeekNamesVisible(boolean visible)
          Specifies whether the week names are visible or not.
 void setWeekNumbersVisible(boolean visible)
          Specifies whether the week numbers are visible or not.
 void setYear(int year)
          Specifies the year that is displayed by this component.
 
Methods inherited from class com.standbysoft.component.date.swing.JDateComponent
addActionListener, addDateSelectionListener, fireActionEvent, fireDateSelectionChanged, fireDisabledDatesChanged, fireEmptySelectionAllowedChanged, fireSelectionModeChanged, getActionCommand, getDateSelectionModel, getLocale, getSelectedDate, getUI, isEmptySelectionAllowed, removeActionListener, removeDateSelectionListener, setActionCommand, setDateSelectionModel, setEmptySelectionAllowed, setSelectedDate, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

DATE_COMMAND

public static final java.lang.String DATE_COMMAND
Action name that indicates a date command. An date command is issued when a date is double clicked.

See Also:
Constant Field Values

monthModelListener

protected MonthModelListener monthModelListener
Listener that takes month model events from the model and fires them further away as events generated by this component.


renderer

protected DateRenderer renderer
Renderer that is used to display the dates of a month.


monthModel

protected MonthModel monthModel

monthBackground

protected java.awt.Color monthBackground

titleBackground

protected java.awt.Color titleBackground

titleForeground

protected java.awt.Color titleForeground

trailingForeground

protected java.awt.Color trailingForeground

gridColor

protected java.awt.Color gridColor

weekNumbersVisible

protected boolean weekNumbersVisible

weekNamesVisible

protected boolean weekNamesVisible

horizontalLinesVisible

protected boolean horizontalLinesVisible

verticalLinesVisible

protected boolean verticalLinesVisible
Constructor Detail

JMonth

public JMonth()
Creates a component that displays the days of a month.


JMonth

public JMonth(MonthModel model)

JMonth

public JMonth(MonthModel model,
              DateSelectionModel dateSelectionModel)
Method Detail

requestFocus

public void requestFocus()

addMonthModelListener

public void addMonthModelListener(MonthModelListener listener)
Registers a month model listener that will receive notifications when the month model model changes. Perhaps one of the main reasons is to be notified when the month displayed by this component changes.

Parameters:
listener - listener that is registered
See Also:
setMonthModel(MonthModel), removeMonthModelListener(MonthModelListener)

removeMonthModelListener

public void removeMonthModelListener(MonthModelListener listener)
Removes a specified month model listener. It will not receive month model events anymore.

Parameters:
listener - removed listener

getMonthModel

public MonthModel getMonthModel()
Returns the month model used by this component.

Returns:
month model used by this component.

setMonthModel

public void setMonthModel(MonthModel model)
Specifies a new month model for this component. The month model is useful to define month specific information like: current month, first day of week, etc.

Parameters:
model - new month model to be used by this component

setDateRenderer

public void setDateRenderer(DateRenderer renderer)
Specify a renderer that will be used to display the dates of the month.

Parameters:
renderer - specified renderer that displays the dates of the month

getDateRenderer

public DateRenderer getDateRenderer()
Returns the renderer used to display the dates of the month.

Returns:
the renderer used to display the dates of the month.

getUIClassID

public java.lang.String getUIClassID()
Returns the name of the L&F class that renders this component.

Returns:
the string "MonthUI"

getDowFirst

public int getDowFirst()
Returns the first day of week.

Returns:
the first day of week.
See Also:
MonthModel.getDowFirst()

setDowFirst

public void setDowFirst(int dow)
Specifies the first day of week.

Parameters:
dow - day of week that is a java.util.Calendar constant like Calendar.MONDAY
See Also:
MonthModel.setDowFirst(int)

setMonth

public void setMonth(int month)
Specifies the month that is displayed by this component. The values are those specified by java.util.Calendar.

Parameters:
month -
See Also:
MonthModel.setMonth(int)

getMonth

public int getMonth()
Returns the month displayed by this component.

Returns:
the month displayed by this component.
See Also:
MonthModel.getMonth(), getYear()

setYear

public void setYear(int year)
Specifies the year that is displayed by this component.

Parameters:
year - year that is displayed by this component.
See Also:
MonthModel.setYear(int)

getYear

public int getYear()
Returns the year that is displayed by this component.

Returns:
year that is displayed by this component.
See Also:
MonthModel.getYear(), getMonth()

setLocale

public void setLocale(java.util.Locale locale)
Specifies a new locale to be used by this component. The locale is very important because it is used to get the right names for the week days and to the first day of week.

Overrides:
setLocale in class JDateComponent
Parameters:
locale - locale to be used by this component

isWeekNumbersVisible

public boolean isWeekNumbersVisible()
Determines whether the week numbers are visible or not.

Returns:
true if the week numbers are visible or false otherwise.

setWeekNumbersVisible

public void setWeekNumbersVisible(boolean visible)
Specifies whether the week numbers are visible or not.

Parameters:
visible - visibility of the week numbers

isWeekNamesVisible

public boolean isWeekNamesVisible()
Determines whether the week names are visible or not.

Returns:
true if the week names are visible or false otherwise.

setWeekNamesVisible

public void setWeekNamesVisible(boolean visible)
Specifies whether the week names are visible or not.

Parameters:
visible - visibility of the week names

isHorizontalLinesVisible

public boolean isHorizontalLinesVisible()
Determines whether the horizontal lines of the grid are visible.

Returns:
true if the horizontal line are visible; false otherwise
See Also:
setHorizontalLinesVisible(boolean)

setHorizontalLinesVisible

public void setHorizontalLinesVisible(boolean visible)
Specifies whether the horizontal lines of the grid are visible.

Parameters:
visible - true if the lines should be visible; false otherwise
See Also:
setVerticalLinesVisible(boolean), setGridColor(Color)

isVerticalLinesVisible

public boolean isVerticalLinesVisible()
Determines whether the vertical lines of the grid are visible.

Returns:
true if the vertical line are visible; false otherwise
See Also:
setVerticalLinesVisible(boolean)

setVerticalLinesVisible

public void setVerticalLinesVisible(boolean visible)
Specifies whether the vertical lines of the grid are visible.

Parameters:
visible - true if the lines should be visible; false otherwise
See Also:
setHorizontalLinesVisible(boolean), setGridColor(Color)

getGridColor

public java.awt.Color getGridColor()
Detrmines the color used to paint the grid.

Returns:
the color used to paint the grid.
See Also:
setGridColor(Color)

setGridColor

public void setGridColor(java.awt.Color color)
Specifies the color used to paint the grid when it is visible.

Parameters:
color - color used to paint the grid
See Also:
setHorizontalLinesVisible(boolean), setVerticalLinesVisible(boolean)

getTitleBackground

public java.awt.Color getTitleBackground()
Returns the background color for the month title.

Returns:
background color for the month title.
See Also:
setTitleBackground(Color)

setTitleBackground

public void setTitleBackground(java.awt.Color color)
Sets the background color for the month title. By default, the background for the currently selected day(s), month and year is painted using this color.

Parameters:
color - new color that is set.
See Also:
setDateRenderer(DateRenderer)

getTitleForeground

public java.awt.Color getTitleForeground()
Returns the foreground color for the month title.

Returns:
foreground color for the month title.
See Also:
setTitleForeground(Color)

setTitleForeground

public void setTitleForeground(java.awt.Color color)
Sets the foreground color for the month title. By default, the currently selected day(s), month and year are painted using this color.

Parameters:
color - new color that is set.
See Also:
setDateRenderer(DateRenderer)

getTrailingForeground

public java.awt.Color getTrailingForeground()
Returns the foreground color for trailing days.

Returns:
the foreground color for trailing days.
See Also:
setTrailingForeground(Color)

setTrailingForeground

public void setTrailingForeground(java.awt.Color color)
Sets the foreground color for trailing days. The trailing days are the days that do not belong to the displayed month.

Parameters:
color - new color that is set
See Also:
setDateRenderer(DateRenderer)

getMonthBackground

public java.awt.Color getMonthBackground()
Returns the background color for the displayed month.

Returns:
background color for the displayed month
See Also:
setMonthBackground(Color)

setMonthBackground

public void setMonthBackground(java.awt.Color color)
Sets the background color for the displayed month.

Parameters:
color - new color that is set
See Also:
setDateRenderer(DateRenderer)

getSelectedDates

public java.util.Date[] getSelectedDates()
Returns the selected dates. Depending on the selection mode, zero, one or more dates are returned. There can be returned zero dates when empty date selection is allowed.

Returns:
the selected dates; the array can be empty when empty selection is allowed
See Also:
JDateComponent.setEmptySelectionAllowed(boolean)

setSelectedDates

public void setSelectedDates(java.util.Date[] dates)
Specifies the dates selected by this component.

Parameters:
dates - array of dates selected by this component. If the array is empty, no date will be selected.
See Also:
getSelectedDates(), setSelectionMode(com.standbysoft.component.date.DateSelectionModel.SelectionMode)

getSelectionMode

public DateSelectionModel.SelectionMode getSelectionMode()
Returns the selection mode used by this component.

Returns:
the selection mode used by this component.

setSelectionMode

public void setSelectionMode(DateSelectionModel.SelectionMode mode)
Specifies a new selection mode to be used by this component. The selection mode tells whether a single date, a date interval or multiple date intervals can be selected.

Parameters:
mode - selection mode to be used by this component
See Also:
JDateComponent.setEmptySelectionAllowed(boolean)

fireMonthChanged

protected void fireMonthChanged(MonthModelEvent evt)

fireDowFirstChanged

protected void fireDowFirstChanged(MonthModelEvent evt)

fireDowNamesFormatChanged

protected void fireDowNamesFormatChanged(MonthModelEvent evt)

fireMonthNamesFormatChanged

protected void fireMonthNamesFormatChanged(MonthModelEvent evt)

Java Date Picker v3.2

Visit www.javadatepicker.com for further information or send us your suggestions.

Copyright © 2003-2004 Stand By Soft Ltd. All Rights Reserved.