public class Calendar extends Container
To localize strings for month names use the values "Calendar.Month" in the resource localization e.g. "Calendar.Jan", "Calendar.Feb" etc...
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
Constructor and Description |
---|
Calendar()
Constructs a calendar with the current date and time
|
Calendar(long time)
Creates a new instance of Calendar set to the given date based on time
since epoch (the java.util.Date convention)
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener l)
Fires when a change is made to the month view of this component
|
void |
addDataChangeListener(DataChangedListener l)
Allows tracking selection changes in the calendar in real time
|
protected Button |
createDay()
This method creates the Day Button Component for the Month View
|
protected Label |
createDayTitle(int day)
This method creates the Day title Component for the Month View
|
protected Button |
createDecrementButton()
This method creates the decrement month button
|
protected Button |
createIncrementButton()
This method creates the increment month button
|
Date |
getDate()
Return the date object matching the current selection
|
Style |
getMonthViewSelectedStyle()
Gets the selected style of the month view component within the calendar
|
Style |
getMonthViewUnSelectedStyle()
Gets the un selected style of the month view component within the calendar
|
long |
getSelectedDay()
Returns the time for the current calendar.
|
void |
paint(Graphics g)
This method paints the Component on the screen, it should be overriden
by subclasses to perform custom drawing or invoke the UI API's to let
the PLAF perform the rendering.
|
void |
removeActionListener(ActionListener l)
Fires when a change is made to the month view of this component
|
void |
removeDataChangeListener(DataChangedListener l)
Allows tracking selection changes in the calendar in real time
|
void |
setCurrentDate(Date d)
Sets the Calendar view on the given date, only the the month and year
are being considered.
|
void |
setDate(Date d)
Sets the current date in the view and the selected date to be the same.
|
void |
setMonthViewSelectedStyle(Style s)
Sets the selected style of the month view component within the calendar
|
void |
setMonthViewUnSelectedStyle(Style s)
Sets the un selected style of the month view component within the calendar
|
void |
setSelectedDate(Date d)
This method sets the Calendar selected day
|
addComponent, addComponent, addComponent, addComponent, applyRTL, calcPreferredSize, contains, flushReplace, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getLayout, getLayoutHeight, getLayoutWidth, getScrollIncrement, invalidate, isScrollableX, isScrollableY, layoutContainer, paintGlass, paramString, pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer, setLayout, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout
addFocusListener, animate, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragInitiated, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getHeight, getLabelForComponent, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getScrollAnimationSpeed, getScrollDimension, getScrollX, getScrollY, getSelectCommandText, getSelectedStyle, getSideGap, getStyle, getUIID, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, handlesInput, hasFocus, initComponent, initCustomStyle, isBorderPainted, isDragActivated, isEnabled, isFocusable, isFocusPainted, isInitialized, isRTL, isScrollable, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerDragged, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setBorderPainted, setDirtyRegion, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setLabelForComponent, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setRTL, setScrollAnimationSpeed, setScrollSize, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setStyle, setTactileTouch, setTensileDragEnabled, setUIID, setUnselectedStyle, setUnSelectedStyle, setVisible, setWidth, setX, setY, styleChanged, toString
public Calendar(long time)
time
- time since epochpublic Calendar()
public long getSelectedDay()
public Date getDate()
public void setDate(Date d)
d
- new datepublic void setSelectedDate(Date d)
d
- the selected daypublic void setCurrentDate(Date d)
d
- the date to set the calendar view on.public void paint(Graphics g)
Component
public void setMonthViewSelectedStyle(Style s)
s
- style for the month viewpublic void setMonthViewUnSelectedStyle(Style s)
s
- style for the month viewpublic Style getMonthViewSelectedStyle()
public Style getMonthViewUnSelectedStyle()
public void addActionListener(ActionListener l)
l
- listener to addpublic void removeActionListener(ActionListener l)
l
- listener to removepublic void addDataChangeListener(DataChangedListener l)
l
- listener to addpublic void removeDataChangeListener(DataChangedListener l)
l
- listener to removeprotected Button createDay()
protected Label createDayTitle(int day)
day
- the relevant day values are 0-6 where 0 is sunday.protected Button createIncrementButton()
protected Button createDecrementButton()