|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.michaelbaranov.microba.common.MicrobaComponent
com.michaelbaranov.microba.calendar.CalendarPane
public class CalendarPane
A concrete implementation of JComponent. Capable of displaying and selecting dates, much like a real-world calendar.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| Field Summary | |
|---|---|
static java.lang.String |
PROPERTY_NAME_DATE
The name of a "date" property. |
static java.lang.String |
PROPERTY_NAME_FOCUS_LOST_BEHAVIOR
The name of a "focusLocatBehavior" property. |
static java.lang.String |
PROPERTY_NAME_HOLIDAY_POLICY
The name of a "holidayPolicy" property. |
static java.lang.String |
PROPERTY_NAME_LOCALE
The name of a "locale" property. |
static java.lang.String |
PROPERTY_NAME_RESOURCES
The name of a "resources" property. |
static java.lang.String |
PROPERTY_NAME_SHOW_NONE_BTN
The name of a "showNoneButton" property. |
static java.lang.String |
PROPERTY_NAME_SHOW_NUMBER_WEEK
The name of a "resources" property. |
static java.lang.String |
PROPERTY_NAME_SHOW_TODAY_BTN
The name of a "showTodayButton" property. |
static java.lang.String |
PROPERTY_NAME_STRIP_TIME
The name of a "stripTime" property. |
static java.lang.String |
PROPERTY_NAME_STYLE
The name of a "style" property. |
static java.lang.String |
PROPERTY_NAME_VETO_POLICY
The name of a "vetoPolicy" property. |
static java.lang.String |
PROPERTY_NAME_ZONE
The name of a "zone" property. |
static int |
STYLE_CLASSIC
A constant for the "style" property. |
static int |
STYLE_MODERN
A constant for the "style" property. |
| Fields inherited from class com.michaelbaranov.microba.common.MicrobaComponent |
|---|
PROPERTY_NAME_COLOR_OVERRIDE_MAP |
| Fields inherited from class javax.swing.JComponent |
|---|
TOOL_TIP_TEXT_KEY, 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 | |
|---|---|
CalendarPane()
Constructor. |
|
CalendarPane(java.util.Date initialDate)
Constructor. |
|
CalendarPane(java.util.Date initialDate,
int style)
Constructor. |
|
CalendarPane(java.util.Date initialDate,
int style,
java.util.Locale locale)
Constructor. |
|
CalendarPane(java.util.Date initialDate,
int style,
java.util.Locale locale,
java.util.TimeZone zone)
Constructor. |
|
CalendarPane(int style)
Constructor. |
|
| Method Summary | |
|---|---|
void |
addActionListener(java.awt.event.ActionListener listener)
Adds an ActionListener listener. |
void |
addCommitListener(CommitListener listener)
Adds an CommitListener listener. |
boolean |
commitEdit()
Forces the control to commit current user's edit. |
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. |
void |
fireActionEvent()
Fires a ActionEvent to all registered listeners. |
void |
fireCommitEvent(boolean commit)
Fires a CommitEvent to all registered listeners. |
java.util.Date |
getDate()
Returns currently selected date in the control. |
int |
getFocusLostBehavior()
Returns the focus lost behavior. |
HolidayPolicy |
getHolidayPolicy()
Returns current holliday policy (model). |
java.util.Locale |
getLocale()
Returns current locale. |
CalendarResources |
getResources()
Resurns current calendar resources model. |
int |
getStyle()
Returns current visual style of the control. |
java.lang.String |
getUIClassID()
|
VetoPolicy |
getVetoPolicy()
Returns the current veto policy (model). |
java.util.TimeZone |
getZone()
Returns current time zone. |
boolean |
isShowNoneButton()
Is the none-button visible? |
boolean |
isShowNumberOfWeek()
Is the number of every week visible? |
boolean |
isShowTodayButton()
Is today button visible? |
boolean |
isStripTime()
Is time protion of the date automatically striped, based on current locale and ime zone? |
void |
removeActionListener(java.awt.event.ActionListener listener)
Removes an ActionListener listener. |
void |
removeCommitListener(CommitListener listener)
Removes an CommitListener listener. |
void |
revertEdit()
Forces the control to revert current user's edit to reflect current control's date. |
void |
setDate(java.util.Date date)
Sets currently selected date to the control. |
void |
setFocusLostBehavior(int behavior)
Sets the focus lost behaviour. |
void |
setHolidayPolicy(HolidayPolicy holidayPolicy)
Sets current holliday policy (model) then updates the control to reflect the policy set. |
void |
setLocale(java.util.Locale locale)
Sets current locale. |
void |
setResources(CalendarResources resources)
Sets current calendar resources model. |
void |
setShowNoneButton(boolean visible)
Shows or hides the none-button. |
void |
setShowNumberOfWeek(boolean visible)
Shows or hides the the number of every week. |
void |
setShowTodayButton(boolean visible)
Shows or hides the today-button. |
void |
setStripTime(boolean stripTime)
Makes getDate() either strip the time portion of the date, or
keep it. |
void |
setStyle(int style)
Sets the current visual style of the control. |
void |
setVetoPolicy(VetoPolicy vetoModel)
Sets the current veto policy (model). |
void |
setZone(java.util.TimeZone zone)
Sets current time zone. |
static java.util.Date |
stripTime(java.util.Date date,
java.util.TimeZone zone,
java.util.Locale locale)
Returns 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, updateUI |
| Methods inherited from class javax.swing.JComponent |
|---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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, update |
| Methods 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, transferFocusBackward, transferFocusDownCycle, validate |
| Methods 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, 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, 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, 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 |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PROPERTY_NAME_DATE
public static final java.lang.String PROPERTY_NAME_LOCALE
public static final java.lang.String PROPERTY_NAME_ZONE
public static final java.lang.String PROPERTY_NAME_STYLE
public static final java.lang.String PROPERTY_NAME_SHOW_TODAY_BTN
public static final java.lang.String PROPERTY_NAME_SHOW_NONE_BTN
public static final java.lang.String PROPERTY_NAME_FOCUS_LOST_BEHAVIOR
public static final java.lang.String PROPERTY_NAME_VETO_POLICY
public static final java.lang.String PROPERTY_NAME_HOLIDAY_POLICY
public static final java.lang.String PROPERTY_NAME_RESOURCES
public static final java.lang.String PROPERTY_NAME_SHOW_NUMBER_WEEK
public static final java.lang.String PROPERTY_NAME_STRIP_TIME
public static final int STYLE_MODERN
public static final int STYLE_CLASSIC
| Constructor Detail |
|---|
public CalendarPane()
public CalendarPane(int style)
public CalendarPane(java.util.Date initialDate)
public CalendarPane(java.util.Date initialDate,
int style)
public CalendarPane(java.util.Date initialDate,
int style,
java.util.Locale locale)
public CalendarPane(java.util.Date initialDate,
int style,
java.util.Locale locale,
java.util.TimeZone zone)
| Method Detail |
|---|
public java.lang.String getUIClassID()
getUIClassID in class javax.swing.JComponentpublic java.util.Date getDate()
The returned date is guaranteed to pass the restriction check by the
current VetoPolicy. Based on the value of stripTime
property, the returned date may be automatically stripped.
stripTime,
stripTime(Date, TimeZone, Locale)
public void setDate(java.util.Date date)
throws java.beans.PropertyVetoException
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 PropertyChangeEvent may be fired, an ActionEvent may be
fired.
date - the date to set
java.beans.PropertyVetoException - if the date is restricted by the current VetoPolicy.getVetoPolicy(),
setVetoPolicy(VetoPolicy),
addActionListener(ActionListener)public java.util.Locale getLocale()
getLocale in class java.awt.Componentpublic void setLocale(java.util.Locale locale)
The locale is used to construct internal Calendar instances and
affects visual representation of the control.
setLocale in class java.awt.Componentlocale - the locale to setpublic java.util.TimeZone getZone()
public void setZone(java.util.TimeZone zone)
The time zone is used to construct internal Calendar instances
and affects visual representation of the control. The dates returned by
getDate() will have all time components set to zero considering
the current locale.
zone - the time zone to setpublic int getStyle()
public void setStyle(int style)
The control is then updated to reflect the new style.
style - the style to setSTYLE_CLASSIC,
STYLE_MODERNpublic boolean isShowTodayButton()
The today button allows the user to quickly select current date.
true if the today button is visible,
false otherwisepublic void setShowTodayButton(boolean visible)
The today-button allows the user to quickly select current date.
visible - true to show the today-button
false to hidepublic boolean isShowNoneButton()
The none-button allows the user to select empty date (null-date, no date).
true if the none-button is visible,
false otherwisepublic void setShowNoneButton(boolean visible)
The none-button allows the user to select empty date (null-date, no date).
visible - true to show the none-button false
to hidepublic int getFocusLostBehavior()
JFormattedTextField.COMMIT
JFormattedTextField.COMMIT_OR_REVERT
JFormattedTextField.REVERT
JFormattedTextField.PERSIST
JFormattedTextFieldpublic void setFocusLostBehavior(int behavior)
JFormattedTextField.COMMIT
JFormattedTextField.COMMIT_OR_REVERT
JFormattedTextField.REVERT
JFormattedTextField.PERSIST
behavior - the focus lost behavior constantJFormattedTextFieldpublic CalendarResources getResources()
The model is used to query localized resources for the control.
CalendarResourcespublic void setResources(CalendarResources resources)
The model is used to query localized resources for the control.
resources - a calendar resources model to set. Should not be
nullCalendarResourcespublic HolidayPolicy getHolidayPolicy()
The policy is used to query holliday dates and holliday descriptions.
null if none setHolidayPolicypublic void setHolidayPolicy(HolidayPolicy holidayPolicy)
The policy is used to query holliday dates and holiday descriptions.
holidayPolicy - a holliday policy to set. May be nullVetoPolicypublic VetoPolicy getVetoPolicy()
The policy is used to veto dates in the control.
null if none setVetoPolicypublic void setVetoPolicy(VetoPolicy vetoModel)
The policy is used to veto dates in the control.
vetoModel - a veto policy to set. May be nullpublic boolean isShowNumberOfWeek()
true if the number of every week is visible,
false otherwisepublic boolean isStripTime()
true if getDate() returns a stripped
date, false otherwisesetStripTime(boolean),
stripTime(Date, TimeZone, Locale)public void setStripTime(boolean stripTime)
getDate() either strip the time portion of the date, or
keep it.
stripTime - true to strip time, false to
keep timepublic void setShowNumberOfWeek(boolean visible)
The number of week is based on the current locale for the component.
visible - true to show the the number of every week
false to hidepublic void addActionListener(java.awt.event.ActionListener listener)
ActionListener listener.
listener - a listener to addActionListenerpublic void removeActionListener(java.awt.event.ActionListener listener)
ActionListener listener.
listener - a listener to removeActionListenerpublic void addCommitListener(CommitListener listener)
CommitListener listener.
listener - a listener to addCommitListenerpublic void removeCommitListener(CommitListener listener)
CommitListener listener.
listener - a listener to removeCommitListenerpublic boolean commitEdit()
CommitEvent is fired.
true if successful, false otherwiserevertEdit(),
getFocusLostBehavior(),
setFocusLostBehavior(int)public void revertEdit()
CommitEvent is fired.
revertEdit(),
getFocusLostBehavior(),
setFocusLostBehavior(int)public void commitOrRevert()
commitEdit(),
revertEdit(),
getFocusLostBehavior(),
setFocusLostBehavior(int)public void fireCommitEvent(boolean commit)
CommitEvent to all registered listeners.
commit - true to indicate commit, false
to indicate revertCommitEvent,
CommitListenerpublic void fireActionEvent()
ActionEvent to all registered listeners.
ActionEvent,
ActionListener
public static java.util.Date stripTime(java.util.Date date,
java.util.TimeZone zone,
java.util.Locale locale)
Examle:
Fri Sep 29 15:57:23 EEST 2006 -> Fri Sep 29 00:00:00 EEST 2006
date - date to strip time fromzone - time zone to get zero fields inlocale - locale to base the calendar on
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||