Class CalendarPane
- All Implemented Interfaces:
CalendarColors,ImageObserver,MenuContainer,Serializable
- Direct Known Subclasses:
DatePicker
- Author:
- Michael Baranov
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of a "date" property.static final StringThe name of a "focusLocatBehavior" property.static final StringThe name of a "holidayPolicy" property.static final StringThe name of a "locale" property.static final StringThe name of a "resources" property.static final StringThe name of a "showNoneButton" property.static final StringThe name of a "resources" property.static final StringThe name of a "showTodayButton" property.static final StringThe name of a "stripTime" property.static final StringThe name of a "style" property.static final StringThe name of a "vetoPolicy" property.static final StringThe name of a "zone" property.static final intA constant for the "style" property.static final intA constant for the "style" property.Fields inherited from class com.michaelbaranov.microba.common.MicrobaComponent
PROPERTY_NAME_COLOR_OVERRIDE_MAPFields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface com.michaelbaranov.microba.calendar.CalendarColors
COLOR_CALENDAR_GRID_BACKGROUND_DISABLED, COLOR_CALENDAR_GRID_BACKGROUND_ENABLED, COLOR_CALENDAR_GRID_FOCUS, COLOR_CALENDAR_GRID_FOREGROUND_DISABLED, COLOR_CALENDAR_GRID_FOREGROUND_ENABLED, COLOR_CALENDAR_GRID_HOLIDAY_FOREGROUND_DISABLED, COLOR_CALENDAR_GRID_HOLIDAY_FOREGROUND_ENABLED, COLOR_CALENDAR_GRID_RESTRICTED, COLOR_CALENDAR_GRID_SELECTION_BACKGROUND_DISABLED, COLOR_CALENDAR_GRID_SELECTION_BACKGROUND_ENABLED, COLOR_CALENDAR_GRID_WEEKEND_FOREGROUND_DISABLED, COLOR_CALENDAR_GRID_WEEKEND_FOREGROUND_ENABLED, COLOR_CALENDAR_HEADER_BACKGROUND_DISABLED, COLOR_CALENDAR_HEADER_BACKGROUND_ENABLED, COLOR_CALENDAR_HEADER_FOREGROUND_DISABLED, COLOR_CALENDAR_HEADER_FOREGROUND_ENABLED, COLOR_CALENDAR_HEADER_FOREGROUND_WEEKEND_DISABLED, COLOR_CALENDAR_HEADER_FOREGROUND_WEEKEND_ENABLEDFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.CalendarPane(int style) Constructor.CalendarPane(Date initialDate) Constructor.CalendarPane(Date initialDate, int style) Constructor.CalendarPane(Date initialDate, int style, Locale locale) Constructor.CalendarPane(Date initialDate, int style, Locale locale, TimeZone zone) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActionListener(ActionListener listener) Adds anActionListenerlistener.voidaddCommitListener(CommitListener listener) Adds anCommitListenerlistener.booleanForces the control to commit current user's edit.voidForces the control to commit or revert user's edit depending on the current focus lost behavior as if the focus would be lost.voidFires aActionEventto all registered listeners.voidfireCommitEvent(boolean commit) Fires aCommitEventto all registered listeners.getDate()Returns currently selected date in the control.intReturns the focus lost behavior.Returns current holliday policy (model).Returns current locale.Resurns current calendar resources model.intgetStyle()Returns current visual style of the control.Returns the current veto policy (model).getZone()Returns current time zone.booleanIs the none-button visible?booleanIs the number of every week visible?booleanIs today button visible?booleanIs time protion of the date automatically striped, based on current locale and ime zone?voidobserveMonth(int year, int month) Makes the widget display given month within given year without actually changing selected date.voidremoveActionListener(ActionListener listener) Removes anActionListenerlistener.voidremoveCommitListener(CommitListener listener) Removes anCommitListenerlistener.voidForces the control to revert current user's edit to reflect current control's date.voidSets currently selected date to the control.voidsetFocusLostBehavior(int behavior) Sets the focus lost behaviour.voidsetHolidayPolicy(HolidayPolicy holidayPolicy) Sets current holliday policy (model) then updates the control to reflect the policy set.voidSets current locale.voidsetResources(CalendarResources resources) Sets current calendar resources model.voidsetShowNoneButton(boolean visible) Shows or hides the none-button.voidsetShowNumberOfWeek(boolean visible) Shows or hides the the number of every week.voidsetShowTodayButton(boolean visible) Shows or hides the today-button.voidsetStripTime(boolean stripTime) MakesgetDate()either strip the time portion of the date, or keep it.voidsetStyle(int style) Sets the current visual style of the control.voidsetVetoPolicy(VetoPolicy vetoModel) Sets the current veto policy (model).voidSets current time zone.static DateReturns same date as given, but time portion (hours, minutes, seconds, fraction of second) set to zero, based on given locale and time zone.Methods inherited from class com.michaelbaranov.microba.common.MicrobaComponent
getColorOverrideMap, getUI, setColorOverrideMap, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
PROPERTY_NAME_DATE
The name of a "date" property.- See Also:
-
PROPERTY_NAME_LOCALE
The name of a "locale" property.- See Also:
-
PROPERTY_NAME_ZONE
The name of a "zone" property.- See Also:
-
PROPERTY_NAME_STYLE
The name of a "style" property.- See Also:
-
PROPERTY_NAME_SHOW_TODAY_BTN
The name of a "showTodayButton" property.- See Also:
-
PROPERTY_NAME_SHOW_NONE_BTN
The name of a "showNoneButton" property.- See Also:
-
PROPERTY_NAME_FOCUS_LOST_BEHAVIOR
The name of a "focusLocatBehavior" property.- See Also:
-
PROPERTY_NAME_VETO_POLICY
The name of a "vetoPolicy" property.- See Also:
-
PROPERTY_NAME_HOLIDAY_POLICY
The name of a "holidayPolicy" property.- See Also:
-
PROPERTY_NAME_RESOURCES
The name of a "resources" property.- See Also:
-
PROPERTY_NAME_SHOW_NUMBER_WEEK
The name of a "resources" property.- See Also:
-
PROPERTY_NAME_STRIP_TIME
The name of a "stripTime" property.- See Also:
-
STYLE_MODERN
public static final int STYLE_MODERNA constant for the "style" property.- See Also:
-
STYLE_CLASSIC
public static final int STYLE_CLASSICA constant for the "style" property.- See Also:
-
-
Constructor Details
-
CalendarPane
public CalendarPane()Constructor. -
CalendarPane
public CalendarPane(int style) Constructor. -
CalendarPane
Constructor. -
CalendarPane
Constructor. -
CalendarPane
Constructor. -
CalendarPane
Constructor.
-
-
Method Details
-
getUIClassID
- Overrides:
getUIClassIDin classJComponent
-
getDate
Returns currently selected date in the control.The returned date is guaranteed to pass the restriction check by the current
VetoPolicy. Based on the value ofstripTimeproperty, the returned date may be automatically stripped.- Returns:
- currently selected date
- See Also:
-
setDate
Sets currently selected date to the control.The given date is checked against the current
VetoPolicy. If the check is passed, the date is transferred to the control and the control is updated to display the date.A
PropertyChangeEventmay be fired, anActionEventmay be fired.- Parameters:
date- the date to set- Throws:
PropertyVetoException- if the date is restricted by the currentVetoPolicy.- See Also:
-
getLocale
Returns current locale. -
setLocale
Sets current locale.The locale is used to construct internal
Calendarinstances and affects visual representation of the control. -
getZone
Returns current time zone.- Returns:
- current time zone
-
setZone
Sets current time zone.The time zone is used to construct internal
Calendarinstances and affects visual representation of the control. The dates returned bygetDate()will have all time components set to zero considering the current locale.- Parameters:
zone- the time zone to set
-
getStyle
public int getStyle()Returns current visual style of the control.- Returns:
- current visual style constant.
-
setStyle
public void setStyle(int style) Sets the current visual style of the control.The control is then updated to reflect the new style.
- Parameters:
style- the style to set- See Also:
-
isShowTodayButton
public boolean isShowTodayButton()Is today button visible?The today button allows the user to quickly select current date.
- Returns:
trueif the today button is visible,falseotherwise
-
setShowTodayButton
public void setShowTodayButton(boolean visible) Shows or hides the today-button.The today-button allows the user to quickly select current date.
- Parameters:
visible-trueto show the today-buttonfalseto hide
-
isShowNoneButton
public boolean isShowNoneButton()Is the none-button visible?The none-button allows the user to select empty date (null-date, no date).
- Returns:
trueif the none-button is visible,falseotherwise
-
setShowNoneButton
public void setShowNoneButton(boolean visible) Shows or hides the none-button.The none-button allows the user to select empty date (null-date, no date).
- Parameters:
visible-trueto show the none-buttonfalseto hide
-
getFocusLostBehavior
public int getFocusLostBehavior()Returns the focus lost behavior. Possible values are: Original meaning preserved.- Returns:
- the focus lost behavior constant
- See Also:
-
setFocusLostBehavior
public void setFocusLostBehavior(int behavior) Sets the focus lost behaviour. Possible values are: Original meaning preserved.- Parameters:
behavior- the focus lost behavior constant- See Also:
-
getResources
Resurns current calendar resources model.The model is used to query localized resources for the control.
- Returns:
- current calendar resources model
- See Also:
-
setResources
Sets current calendar resources model.The model is used to query localized resources for the control.
- Parameters:
resources- a calendar resources model to set. Should not benull- See Also:
-
getHolidayPolicy
Returns current holliday policy (model).The policy is used to query holliday dates and holliday descriptions.
- Returns:
- current holliday policy or
nullif none set - See Also:
-
setHolidayPolicy
Sets current holliday policy (model) then updates the control to reflect the policy set.The policy is used to query holliday dates and holiday descriptions.
- Parameters:
holidayPolicy- a holliday policy to set. May benull- See Also:
-
getVetoPolicy
Returns the current veto policy (model).The policy is used to veto dates in the control.
- Returns:
- current veto policy or
nullif none set - See Also:
-
setVetoPolicy
Sets the current veto policy (model).The policy is used to veto dates in the control.
- Parameters:
vetoModel- a veto policy to set. May benull
-
isShowNumberOfWeek
public boolean isShowNumberOfWeek()Is the number of every week visible?- Returns:
trueif the number of every week is visible,falseotherwise
-
isStripTime
public boolean isStripTime()Is time protion of the date automatically striped, based on current locale and ime zone?- Returns:
trueifgetDate()returns a stripped date,falseotherwise- See Also:
-
setStripTime
public void setStripTime(boolean stripTime) MakesgetDate()either strip the time portion of the date, or keep it.- Parameters:
stripTime-trueto strip time,falseto keep time
-
setShowNumberOfWeek
public void setShowNumberOfWeek(boolean visible) Shows or hides the the number of every week.The number of week is based on the current locale for the component.
- Parameters:
visible-trueto show the the number of every weekfalseto hide
-
addActionListener
Adds anActionListenerlistener.- Parameters:
listener- a listener to add- See Also:
-
removeActionListener
Removes anActionListenerlistener.- Parameters:
listener- a listener to remove- See Also:
-
addCommitListener
Adds anCommitListenerlistener.- Parameters:
listener- a listener to add- See Also:
-
removeCommitListener
Removes anCommitListenerlistener.- Parameters:
listener- a listener to remove- See Also:
-
commitEdit
public boolean commitEdit()Forces the control to commit current user's edit. The opertaion may fail because the date in the control may be restricted by current veto policy. If successfull, the current date of the control may change, aCommitEventis fired.- Returns:
trueif successful,falseotherwise- See Also:
-
revertEdit
public void revertEdit()Forces the control to revert current user's edit to reflect current control's date. The current date of the control may change, aCommitEventis fired.- See Also:
-
commitOrRevert
public void commitOrRevert()Forces the control to commit or revert user's edit depending on the current focus lost behavior as if the focus would be lost.- See Also:
-
fireCommitEvent
public void fireCommitEvent(boolean commit) Fires aCommitEventto all registered listeners.- Parameters:
commit-trueto indicate commit,falseto indicate revert- See Also:
-
fireActionEvent
public void fireActionEvent()Fires aActionEventto all registered listeners.- See Also:
-
stripTime
Returns same date as given, but time portion (hours, minutes, seconds, fraction of second) set to zero, based on given locale and time zone. Utility method.Examle:
Fri Sep 29 15:57:23 EEST 2006 -> Fri Sep 29 00:00:00 EEST 2006- Parameters:
date- date to strip time fromzone- time zone to get zero fields inlocale- locale to base the calendar on- Returns:
- stripped date
-
observeMonth
public void observeMonth(int year, int month) Makes the widget display given month within given year without actually changing selected date.- Parameters:
year- year to showmonth- month within the year to show
-