|
||||||||||
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
javax.swing.JPanel
uk.co.keang.date.AbstractDateSelector<T>
public abstract class AbstractDateSelector<T>
An abstract Date Selection GUI.
Displays a calendar style view of the days in a month. The month and year can be easily
changed via drop down controls and/or by month increment buttons and the day selected by
clicking on a day button.
If todays date is visible ie the panel is showing the todays month and year then the text on the button with todays day is coloured RED.
As well as being able to select a date using the mouse the following key-strokes are recognised:
LEFT: move back 1 day
RIGHT: move forward one day
UP: move back 1 week
DOWN: move forward 1 week
PAGE_UP: move back 1 month
PAGE_DOWN: move forward 1 month
HOME: move back 1 year
END: move forward 1 year
ESC: cancel any selected date and hide the panel
ENTER: retain the selected date and hide the panel
Listeners can be added to receive notification of a change of selected date and/or the selection of
a day button.
Factory methods are provided to:
1. Create a dialog to show the selector optionally with OK/Cancel buttons
2. Attach a popup-on-hover feature to a component to popup a date selector if the mouse hovers over
the component.
The chronology of the initial date is maintained throughout the life of this object.
Nested Class Summary | |
---|---|
static class |
AbstractDateSelector.DayButton
JToggleButton that knows what day it represents |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
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 static java.lang.String |
ACTION_NAME_DAY_DEC
|
protected static java.lang.String |
ACTION_NAME_DAY_INC
|
protected static java.lang.String |
ACTION_NAME_ENTER
|
protected static java.lang.String |
ACTION_NAME_ESC
|
protected static java.lang.String |
ACTION_NAME_MONTH_DEC
|
protected static java.lang.String |
ACTION_NAME_MONTH_INC
|
protected static java.lang.String |
ACTION_NAME_WEEK_DEC
|
protected static java.lang.String |
ACTION_NAME_WEEK_INC
|
protected static java.lang.String |
ACTION_NAME_YEAR_DEC
|
protected static java.lang.String |
ACTION_NAME_YEAR_INC
|
protected org.joda.time.MutableDateTime |
baseDate
|
protected org.joda.time.Chronology |
chronology
|
protected org.joda.time.MutableDateTime |
movingDate
|
protected java.awt.Window |
window
|
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 | |
---|---|
AbstractDateSelector(org.joda.time.DateTime base,
org.joda.time.DateTime end,
boolean includeOkCancel)
Construct the panel for the default locale |
|
AbstractDateSelector(org.joda.time.DateTime base,
org.joda.time.DateTime end,
boolean includeOkCancel,
java.util.Locale loc)
Construct the panel |
Method Summary | |
---|---|
void |
addDateChangedListener(javax.swing.event.ChangeListener l)
Adds an date change listener. |
void |
addDayActionListener(java.awt.event.ActionListener l)
Adds an action listener to each of the day buttons. |
(package private) static javax.swing.JDialog |
createDialog(java.awt.Component owner,
java.lang.String title,
AbstractDateSelector panel)
Displays a modal dialog allowing the selection of a date. |
protected void |
fireDateChangeListener()
fires the date change event to all listeners |
protected void |
fireDayBtnListener(java.awt.event.ActionEvent e)
fires the day selected event to all listeners |
abstract T |
getSelectedDate()
Gets the selected date |
(package private) static java.awt.Window |
getWindowForComponent(java.awt.Component parentComponent)
Gets the window owner of this component |
protected void |
initKeyActions()
init the key strokes that have meaning for this panel |
boolean |
isShowDayNames()
Gets the Show Day Names display state |
boolean |
isShowOkCancelPanel()
Gets the Show OK Cancel Panel |
boolean |
isShowSurroundingDays()
Gets the Show Surrounding Days display state |
boolean |
isShowWeekNums()
Gets the Show Week Numbers state |
void |
removeDateChangedListener(javax.swing.event.ChangeListener l)
Removes the date change listener |
void |
removeDayActionListener(java.awt.event.ActionListener l)
Removes the action listener from each of the day buttons. |
(package private) static void |
removePopupOnHoverFromComponent(java.awt.Component owner)
Removes the Popup on hover functionality from this component |
void |
setCancelBtnAction(javax.swing.Action a)
Sets the action for the Cancel button |
void |
setFont(java.awt.Font f)
Sets the Font for all the components. |
void |
setOkBtnAction(javax.swing.Action a)
Sets the action for the OK button |
(package private) static void |
setPopupOnHoverForComponent(java.awt.Component owner,
java.util.concurrent.Callable callBack)
Adds a pop up listener to this component. |
abstract void |
setSelectedDate(T date)
Sets the selected date. |
void |
setShowDayNames(boolean show)
Sets the Show Day Names display state |
void |
setShowOkCancelPanel(boolean show)
Sets the Show Ok Cancel Panel state |
void |
setShowSurroundingDays(boolean show)
Sets the Show Surrounding Days display state |
void |
setShowWeekNums(boolean show)
Sets the Show Week Numbers state |
protected void |
updateOnSettingSelectedDate()
|
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, 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, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String ACTION_NAME_ENTER
protected static final java.lang.String ACTION_NAME_ESC
protected static final java.lang.String ACTION_NAME_YEAR_INC
protected static final java.lang.String ACTION_NAME_YEAR_DEC
protected static final java.lang.String ACTION_NAME_MONTH_INC
protected static final java.lang.String ACTION_NAME_MONTH_DEC
protected static final java.lang.String ACTION_NAME_WEEK_INC
protected static final java.lang.String ACTION_NAME_WEEK_DEC
protected static final java.lang.String ACTION_NAME_DAY_INC
protected static final java.lang.String ACTION_NAME_DAY_DEC
protected java.awt.Window window
protected org.joda.time.MutableDateTime baseDate
protected org.joda.time.MutableDateTime movingDate
protected org.joda.time.Chronology chronology
Constructor Detail |
---|
public AbstractDateSelector(org.joda.time.DateTime base, org.joda.time.DateTime end, boolean includeOkCancel)
base
- - the base dateend
- - the end date, this may be before or after the base dateincludeOkCancel
- - true to include a panel with OK and Cancel buttonspublic AbstractDateSelector(org.joda.time.DateTime base, org.joda.time.DateTime end, boolean includeOkCancel, java.util.Locale loc)
base
- - the base dateend
- - the end date, this may be before or after the base dateincludeOkCancel
- - true to include a panel with OK and Cancel buttonsloc
- - the locale to use or null for the default localeMethod Detail |
---|
static void setPopupOnHoverForComponent(java.awt.Component owner, java.util.concurrent.Callable callBack)
The given listener will be called only if the panel closes due to a day being selected or the ENTER key is pressed
owner
- - the component to add the hover popup listener tocallBack
- - a callable object that will be called when a day button is selectedstatic void removePopupOnHoverFromComponent(java.awt.Component owner)
owner
- - the componentstatic javax.swing.JDialog createDialog(java.awt.Component owner, java.lang.String title, AbstractDateSelector panel)
owner
- - the owning component or nulltitle
- - The title to display in the dialog frame or null for no titlepanel
- - the panel
static java.awt.Window getWindowForComponent(java.awt.Component parentComponent) throws java.awt.HeadlessException
parentComponent
- - the component
java.awt.HeadlessException
- if there is no window ownerprotected void initKeyActions()
public abstract T getSelectedDate()
public abstract void setSelectedDate(T date)
date
- - the selected dateprotected void updateOnSettingSelectedDate()
public boolean isShowWeekNums()
public void setShowWeekNums(boolean show)
show
- - true to display week numbers, false to hide thempublic boolean isShowDayNames()
public void setShowDayNames(boolean show)
show
- - true to display Day Names, false to hide thempublic boolean isShowSurroundingDays()
public void setShowSurroundingDays(boolean show)
show
- - true to display Surrounding Days, false to hide thempublic boolean isShowOkCancelPanel()
public void setShowOkCancelPanel(boolean show)
show
- - true to display OK Cancel Panelpublic void addDayActionListener(java.awt.event.ActionListener l)
l
- - the listener to addpublic void removeDayActionListener(java.awt.event.ActionListener l)
l
- - the listener to removepublic void addDateChangedListener(javax.swing.event.ChangeListener l)
l
- - the listener to addpublic void removeDateChangedListener(javax.swing.event.ChangeListener l)
l
- - the listener to removeprotected void fireDateChangeListener()
protected void fireDayBtnListener(java.awt.event.ActionEvent e)
e
- - the event to firepublic void setFont(java.awt.Font f)
setFont
in class javax.swing.JComponent
f
- - the new fontpublic void setOkBtnAction(javax.swing.Action a)
a
- - the action to usepublic void setCancelBtnAction(javax.swing.Action a)
a
- - the action to use
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |