public class DateChooser extends KPanel implements ActionListener
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
private ActionSupport |
asupport |
private JToggleButton[] |
b_days |
private KButton |
b_lmonth |
private KButton |
b_lyear |
private KButton |
b_rmonth |
private KButton |
b_ryear |
static int |
CELL_SIZE
The default cell size.
|
private boolean |
clipAllMax |
private boolean |
clipAllMin |
private boolean |
clipMax |
private boolean |
clipMin |
static String |
DATE_CHANGE_CMD
Date changed event command.
|
private SimpleDateFormat |
datefmt |
private static int[] |
daysInMonth |
private static int[] |
daysInMonthLeap |
private int |
firstCell |
private int |
firstDay |
private int |
fontHeight |
private ButtonGroup |
group |
private KLabel |
l_date |
private KLabel[] |
l_days |
private KLabel |
l_month |
private KLabel |
l_year |
private String[] |
labels |
private Calendar |
maxDate |
private int |
maxDay |
private Calendar |
minDate |
private int |
minDay |
static String |
MONTH_CHANGE_CMD
Month changed event command.
|
private String[] |
months |
private Calendar |
selectedDate |
private int |
selectedDay |
private static Color |
weekendColor |
private int[] |
weekendCols |
static String |
YEAR_CHANGE_CMD
Year changed event command.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
DateChooser()
Construct a new
DateChooser . |
DateChooser(Calendar date)
Construct a new
DateChooser with the specified selected
date. |
Modifier and Type | Method and Description |
---|---|
private void |
_computeFirstDay() |
private void |
_refresh() |
private void |
_refreshDate() |
void |
actionPerformed(ActionEvent evt)
Handle events.
|
void |
addActionListener(ActionListener listener)
Add a
ActionListener to this component's list of listeners. |
private Calendar |
copyDate(Calendar source,
Calendar dest) |
Calendar |
getMaximumDate()
Get the latest selectable date for the chooser.
|
Calendar |
getMinimumDate()
Get the earliest selectable date for the chooser.
|
Calendar |
getSelectedDate()
Get a copy of the
Calendar object that represents the
currently selected date. |
static boolean |
isLeapYear(int year)
Determine if a year is a leap year.
|
void |
removeActionListener(ActionListener listener)
Remove a
ActionListener from this component's list of
listeners. |
void |
setCellSize(int cellSize)
Set the size of date cells in the calendar pane.
|
void |
setDateFormat(SimpleDateFormat format)
Set the format for the textual date display at the bottom of the
component.
|
void |
setMaximumDate(Calendar date)
Set the latest selectable date for the chooser.
|
void |
setMinimumDate(Calendar date)
Set the earliest selectable date for the chooser.
|
void |
setSelectedDate(Calendar date)
Set the selected date for the chooser.
|
getComponentByName, paintComponent, setFocusOrder, setTexture
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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, transferFocusDownCycle, validate, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
private SimpleDateFormat datefmt
private Calendar selectedDate
private int selectedDay
private int firstDay
private int minDay
private int maxDay
private int firstCell
private JToggleButton[] b_days
private static final int[] daysInMonth
private static final int[] daysInMonthLeap
private static final Color weekendColor
private boolean clipMin
private boolean clipMax
private boolean clipAllMin
private boolean clipAllMax
private int[] weekendCols
private ActionSupport asupport
private int fontHeight
private ButtonGroup group
public static final int CELL_SIZE
public static final String DATE_CHANGE_CMD
public static final String MONTH_CHANGE_CMD
public static final String YEAR_CHANGE_CMD
public DateChooser()
DateChooser
. The selection will be
initialized to the current date.public DateChooser(Calendar date)
DateChooser
with the specified selected
date.date
- The date for the selection.public Calendar getSelectedDate()
Calendar
object that represents the
currently selected date.public void setSelectedDate(Calendar date)
date
- The date to select.public void setMinimumDate(Calendar date)
date
- The (possibly null
) minimum selectable date.public Calendar getMinimumDate()
null
if there is no
minimum date currently set.public void setMaximumDate(Calendar date)
date
- The (possibly null
) maximum selectable date.public Calendar getMaximumDate()
null
if there is no
maximum date currently set.public void setDateFormat(SimpleDateFormat format)
format
- The new date format to use.public void actionPerformed(ActionEvent evt)
actionPerformed
in interface ActionListener
private void _computeFirstDay()
private void _refreshDate()
private void _refresh()
public static boolean isLeapYear(int year)
year
- The year to check.true
if the year is a leap year, and
false
otherwise.public void addActionListener(ActionListener listener)
ActionListener
to this component's list of listeners.listener
- The listener to add.public void removeActionListener(ActionListener listener)
ActionListener
from this component's list of
listeners.listener
- The listener to remove.public void setCellSize(int cellSize)
cellSize
- The width and height, in pixels, of a cell.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses