|
||||||||||
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.Interval>
uk.co.keang.date.IntervalSelector
public class IntervalSelector
A Date Interval selection GUI.
Displays a calendar style view of the days in a month. Two dates are involved in selecting an
interval, the base date is selected by selecting any day whilst the shift key is not pressed
and the second date is selected by selecting any day whilst the shift key is pressed. The month and year can be easily
changed via drop down controls and/or by month increment buttons and the day 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 the base date back 1 day
RIGHT: move the base date forward one day
UP: move the base date back 1 week
DOWN: move the base date forward 1 week
PAGE_UP: move the base date back 1 month
PAGE_DOWN: move the base date forward 1 month
HOME: move the base date back 1 year
END: move the base date forward 1 year
SHIFT+LEFT: move the second date back 1 day
SHIFT+RIGHT: move the second date forward one day
SHIFT+UP: move the second date back 1 week
SHIFT+DOWN: move the second date forward 1 week
SHIFT+PAGE_UP: move the second date back 1 month
SHIFT+PAGE_DOWN: move the second date forward 1 month
SHIFT+HOME: move the second date back 1 year
SHIFT+END: move the second date 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 |
IntervalSelector.PopupIntervalSelector
The Popup panel for displaying this Interval Selector |
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 | |
---|---|
IntervalSelector(org.joda.time.DateTime base,
org.joda.time.DateTime end,
boolean includeOkCancel)
Construct an IntervalSelector. |
|
IntervalSelector(org.joda.time.DateTime base,
org.joda.time.DateTime end,
boolean includeOkCancel,
java.util.Locale loc)
Construct an IntervalSelector. |
|
IntervalSelector(org.joda.time.Interval interval,
boolean includeOkCancel)
Construct an IntervalSelector. |
|
IntervalSelector(org.joda.time.Interval interval,
boolean includeOkCancel,
java.util.Locale loc)
Construct an IntervalSelector. |
Method Summary | |
---|---|
static IntervalSelector.PopupIntervalSelector |
createPopup(java.awt.Component owner,
org.joda.time.Interval interval)
Creates a popup panel allowing the selection of a date interval. |
static IntervalSelector.PopupIntervalSelector |
createPopup(java.awt.Component owner,
IntervalSelector panel)
Creates a popup panel allowing the selection of a date interval. |
org.joda.time.Interval |
getSelectedDate()
Gets the selected date interval. |
protected void |
initKeyActions()
init the key strokes that have meaning for this panel |
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.MutableInterval dt,
java.awt.event.ActionListener l)
Adds a pop up listener to this component. |
void |
setSelectedDate(org.joda.time.DateTime base,
org.joda.time.DateTime end)
Sets the selected date interval. |
void |
setSelectedDate(org.joda.time.Interval date)
Sets the selected date interval. |
static org.joda.time.Interval |
show(java.awt.Component owner,
java.lang.String title,
org.joda.time.Interval now)
Displays a modal dialog allowing the selection of a date interval. |
static org.joda.time.Interval |
show(java.awt.Component owner,
java.lang.String title,
IntervalSelector panel)
Displays a modal dialog allowing the selection of a date interval. |
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 IntervalSelector(org.joda.time.Interval interval, boolean includeOkCancel)
An interval is half inclusive ie the start date is inclusive and the end date is exclusive.
interval
- - the initial date intervalincludeOkCancel
- - true to include a panel with OK and Cancel buttonspublic IntervalSelector(org.joda.time.Interval interval, boolean includeOkCancel, java.util.Locale loc)
interval
- - the initial date intervalincludeOkCancel
- - true to include a panel with OK and Cancel buttonspublic IntervalSelector(org.joda.time.DateTime base, org.joda.time.DateTime end, boolean includeOkCancel)
These values are both inclusive
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 IntervalSelector(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 buttonsMethod Detail |
---|
public static void setPopupOnHoverForComponent(java.awt.Component owner, org.joda.time.MutableInterval 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 is 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 IntervalSelector.PopupIntervalSelector createPopup(java.awt.Component owner, org.joda.time.Interval interval)
owner
- - the owning component or nullinterval
- - the time now
public static IntervalSelector.PopupIntervalSelector createPopup(java.awt.Component owner, IntervalSelector panel)
This method is provided to allow an IntervalSelector pane to be constructed, configured and then displayed.
owner
- - the owning component or nullpanel
- - the panel
public static org.joda.time.Interval show(java.awt.Component owner, java.lang.String title, org.joda.time.Interval 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.Interval show(java.awt.Component owner, java.lang.String title, IntervalSelector panel)
This method is provided to allow an IntervalSelector 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
protected void initKeyActions()
initKeyActions
in class AbstractDateSelector<org.joda.time.Interval>
public org.joda.time.Interval getSelectedDate()
The returned interval is half inclusive ie the start date is inclusive and the end date is exclusive.
getSelectedDate
in class AbstractDateSelector<org.joda.time.Interval>
public void setSelectedDate(org.joda.time.Interval date)
The interval is half inclusive ie the start date is inclusive and the end date is exclusive.
setSelectedDate
in class AbstractDateSelector<org.joda.time.Interval>
date
- - the selected datepublic void setSelectedDate(org.joda.time.DateTime base, org.joda.time.DateTime end)
The dates are fully inclusive
base
- - the base dateend
- - the end date, this may be before or after the base date
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |