|
||||||||||
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<org.joda.time.DateTime>
uk.co.keang.date.DateSelector
public class DateSelector
A 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. Show the selector in a JDialog optionally with OK/Cancel buttons
2. Show the selector in a Popup style panel
3. Attach a popup-on-hover feature to a component to popup a date selector if the mouse hovers over
the component.
Alternatively the panel can be constructed directly and added to an existing GUI.
Nested Class Summary | |
---|---|
static class |
DateSelector.PopupDateSelector
The Popup panel for displaying this panel |
Nested classes/interfaces inherited from class uk.co.keang.date.AbstractDateSelector |
---|
AbstractDateSelector.DayButton |
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 |
---|
Fields inherited from class uk.co.keang.date.AbstractDateSelector |
---|
ACTION_NAME_DAY_DEC, ACTION_NAME_DAY_INC, ACTION_NAME_ENTER, ACTION_NAME_ESC, ACTION_NAME_MONTH_DEC, ACTION_NAME_MONTH_INC, ACTION_NAME_WEEK_DEC, ACTION_NAME_WEEK_INC, ACTION_NAME_YEAR_DEC, ACTION_NAME_YEAR_INC, baseDate, chronology, movingDate, 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 | |
---|---|
DateSelector(org.joda.time.DateTime now,
boolean includeOkCancel)
Construct a DateSelector for the default locale |
|
DateSelector(org.joda.time.DateTime now,
boolean includeOkCancel,
java.util.Locale loc)
Construct a DateSelector |
Method Summary | |
---|---|
static DateSelector.PopupDateSelector |
createPopup(java.awt.Component owner,
DateSelector panel)
Creates a popup panel allowing the selection of a date. |
static DateSelector.PopupDateSelector |
createPopup(java.awt.Component owner,
org.joda.time.DateTime now)
Creates a popup panel allowing the selection of a date. |
org.joda.time.DateTime |
getSelectedDate()
Gets the selected date |
static void |
removePopupOnHoverFromComponent(java.awt.Component owner)
Removes the Popup on hover functionality from this component |
static void |
setPopupOnHoverForComponent(java.awt.Component owner,
org.joda.time.MutableDateTime dt,
java.awt.event.ActionListener l)
Adds a pop up listener to this component. |
void |
setSelectedDate(org.joda.time.DateTime date)
Sets the selected date |
static org.joda.time.DateTime |
show(java.awt.Component owner,
java.lang.String title,
DateSelector panel)
Displays a modal dialog allowing the selection of a date. |
static org.joda.time.DateTime |
show(java.awt.Component owner,
java.lang.String title,
org.joda.time.DateTime now)
Displays a modal dialog allowing the selection of a date |
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 |
Constructor Detail |
---|
public DateSelector(org.joda.time.DateTime now, boolean includeOkCancel)
now
- - the initial dateincludeOkCancel
- - true to include a panel with OK and Cancel buttonspublic DateSelector(org.joda.time.DateTime now, boolean includeOkCancel, java.util.Locale loc)
now
- - the initial dateincludeOkCancel
- - true to include a panel with OK and Cancel buttonsloc
- - the locale to useMethod Detail |
---|
public static void setPopupOnHoverForComponent(java.awt.Component owner, org.joda.time.MutableDateTime dt, java.awt.event.ActionListener l)
The panel will close when: 1. a day button is selected 2. the mouse moves out of the panel 3. the ESCAPE key is pressed 4. the ENTER key is pressed
The given listener will be called only if the panel closes due to a day being selected or the ENTER key being pressed
owner
- - the component to add the hover popup listener todt
- - the date that will display when the popup pops up. This objects date can be dynamically
changed by the calling code to change the date that displays on popupl
- - a listener that will be called when a day button is selectedpublic static void removePopupOnHoverFromComponent(java.awt.Component owner)
owner
- - the componentpublic static DateSelector.PopupDateSelector createPopup(java.awt.Component owner, org.joda.time.DateTime now)
owner
- - the owning component or nullnow
- - the time now
public static DateSelector.PopupDateSelector createPopup(java.awt.Component owner, DateSelector panel)
This method is provided to allow a DateSelector pane to be constructed, configured and then displayed.
owner
- - the owning component or nullpanel
- - the panel
public static org.joda.time.DateTime show(java.awt.Component owner, java.lang.String title, org.joda.time.DateTime now)
owner
- - the owning component or nulltitle
- - The title to display in the dialog frame or null for no titlenow
- - the time now
public static org.joda.time.DateTime show(java.awt.Component owner, java.lang.String title, DateSelector panel)
This method is provided to allow a DateSelector pane to be constructed, configured and then displayed.
owner
- - the owning component or nulltitle
- - The title to display in the dialog frame or null for no titlepanel
- - the panel
public org.joda.time.DateTime getSelectedDate()
getSelectedDate
in class AbstractDateSelector<org.joda.time.DateTime>
public void setSelectedDate(org.joda.time.DateTime date)
setSelectedDate
in class AbstractDateSelector<org.joda.time.DateTime>
date
- - the selected date
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |