public class DateTime extends Composite
Note that although this class is a subclass of Composite
,
it does not make sense to add children to it, or set a layout on it.
Note: Only one of the styles DATE, TIME, or CALENDAR may be specified, and only one of the styles SHORT, MEDIUM, or LONG may be specified. The DROP_DOWN style is a HINT, and it is only valid with the DATE style.
IMPORTANT: This class is not intended to be subclassed.
Modifier and Type | Field and Description |
---|---|
(package private) static char |
AMPM_FORMAT_CONSTANT |
(package private) static TCHAR |
CalendarClass |
(package private) static int |
CalendarProc |
(package private) static TCHAR |
DateTimeClass |
(package private) static int |
DateTimeProc |
(package private) static char |
DAY_FORMAT_CONSTANT |
(package private) static int |
DAY_MONTH_YEAR |
(package private) boolean |
doubleClick |
(package private) static char |
HOURS_FORMAT_CONSTANT |
(package private) boolean |
ignoreSelection |
(package private) SYSTEMTIME |
lastSystemTime |
(package private) static int |
MARGIN |
(package private) static int |
MAX_12HOUR |
(package private) static int |
MAX_24HOUR |
(package private) static int |
MAX_DAY |
(package private) static int |
MAX_DIGIT |
(package private) static int |
MAX_MINUTE |
(package private) static int |
MAX_YEAR |
(package private) static int |
MIN_YEAR |
(package private) static char |
MINUTES_FORMAT_CONSTANT |
(package private) static int |
MONTH_DAY_YEAR |
(package private) static char |
MONTH_FORMAT_CONSTANT |
(package private) static int[] |
MONTH_NAMES |
(package private) static char |
SECONDS_FORMAT_CONSTANT |
(package private) static char |
SINGLE_QUOTE |
(package private) SYSTEMTIME |
time |
(package private) static char |
YEAR_FORMAT_CONSTANT |
(package private) static int |
YEAR_MONTH_DAY |
backgroundMode, layout, layoutCount, lpwp, tabList
horizontalBar, verticalBar
accessible, background, backgroundImage, cursor, drawCount, font, foreground, handle, layoutData, menu, parent, region, toolTipText
CANVAS, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DISABLED, display, DISPOSE_SENT, DISPOSED, DRAG_DETECT, DRAW_BACKGROUND, eventTable, FOREIGN_HANDLE, HIDDEN, IGNORE_WM_CHANGEUISTATE, KEYED_DATA, LAYOUT_CHANGED, LAYOUT_CHILD, LAYOUT_NEEDED, MAJOR, MINOR, MOVE_DEFERRED, MOVE_OCCURRED, PARENT_BACKGROUND, RELEASED, RESIZE_DEFERRED, RESIZE_OCCURRED, SKIN_NEEDED, state, style, THEME_BACKGROUND, TRACK_MOUSE
Constructor and Description |
---|
DateTime(Composite parent,
int style)
Constructs a new instance of this class given its parent
and a style value describing its behavior and appearance.
|
Modifier and Type | Method and Description |
---|---|
void |
addSelectionListener(SelectionListener listener)
Adds the listener to the collection of listeners who will
be notified when the control is selected by the user, by sending
it one of the messages defined in the
SelectionListener
interface. |
(package private) int |
callWindowProc(int hwnd,
int msg,
int wParam,
int lParam) |
(package private) static int |
checkStyle(int style) |
protected void |
checkSubclass()
Checks that this class can be subclassed.
|
Point |
computeSize(int wHint,
int hHint,
boolean changed)
Returns the preferred size of the receiver.
|
(package private) void |
createHandle() |
(package private) int |
defaultBackground() |
(package private) java.lang.String |
getCustomShortDateFormat() |
(package private) java.lang.String |
getCustomShortTimeFormat() |
int |
getDay()
Returns the receiver's date, or day of the month.
|
int |
getHours()
Returns the receiver's hours.
|
int |
getMinutes()
Returns the receiver's minutes.
|
int |
getMonth()
Returns the receiver's month.
|
(package private) java.lang.String |
getNameText() |
int |
getSeconds()
Returns the receiver's seconds.
|
(package private) java.lang.String |
getTimeFormat() |
int |
getYear()
Returns the receiver's year.
|
(package private) void |
releaseWidget() |
void |
removeSelectionListener(SelectionListener listener)
Removes the listener from the collection of listeners who will
be notified when the control is selected by the user.
|
void |
setDate(int year,
int month,
int day)
Sets the receiver's year, month, and day in a single operation.
|
void |
setDay(int day)
Sets the receiver's date, or day of the month, to the specified day.
|
void |
setHours(int hours)
Sets the receiver's hours.
|
void |
setMinutes(int minutes)
Sets the receiver's minutes.
|
void |
setMonth(int month)
Sets the receiver's month.
|
void |
setOrientation(int orientation)
Sets the orientation of the receiver, which must be one
of the constants
SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT . |
void |
setSeconds(int seconds)
Sets the receiver's seconds.
|
void |
setTime(int hours,
int minutes,
int seconds)
Sets the receiver's hours, minutes, and seconds in a single operation.
|
void |
setYear(int year)
Sets the receiver's year.
|
(package private) int |
widgetStyle() |
(package private) TCHAR |
windowClass() |
(package private) int |
windowProc() |
(package private) LRESULT |
WM_CHAR(int wParam,
int lParam) |
(package private) LRESULT |
WM_LBUTTONDBLCLK(int wParam,
int lParam) |
(package private) LRESULT |
WM_LBUTTONDOWN(int wParam,
int lParam) |
(package private) LRESULT |
WM_LBUTTONUP(int wParam,
int lParam) |
(package private) LRESULT |
WM_TIMER(int wParam,
int lParam) |
(package private) LRESULT |
wmNotifyChild(NMHDR hdr,
int wParam,
int lParam) |
_getChildren, _getTabList, changed, checkBuffered, checkComposited, computeTabList, copyArea, drawBackground, findDeferredControl, findMenus, fixChildren, fixTabList, getBackgroundMode, getChildren, getChildrenCount, getLayout, getLayoutDeferred, getTabList, hooksKeys, isLayoutDeferred, layout, layout, layout, layout, layout, markLayout, minimumSize, redrawChildren, releaseChildren, releaseParent, removeControl, resizeChildren, resizeChildren, resizeEmbeddedHandle, reskinChildren, sendResize, setBackgroundMode, setBounds, setFocus, setLayout, setLayoutDeferred, setResizeChildren, setTabGroupFocus, setTabList, toolTipText, translateMnemonic, translateTraversal, updateBackgroundColor, updateBackgroundImage, updateBackgroundMode, updateFont, updateLayout, updateLayout, updateOrientation, updateUIState, WM_ERASEBKGND, WM_GETDLGCODE, WM_GETFONT, WM_NCHITTEST, WM_PAINT, WM_PARENTNOTIFY, WM_PRINTCLIENT, WM_SETFONT, WM_SIZE, WM_SYSCOLORCHANGE, WM_SYSCOMMAND, WM_UPDATEUISTATE, wmNCPaint, wmNotify
computeTrim, createScrollBar, createWidget, destroyScrollBar, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, scrolledHandle, widgetExtStyle, WM_HSCROLL, WM_MOUSEWHEEL, WM_VSCROLL, wmScroll, wmScrollWheel
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, binarySearch, borderHandle, checkBackground, checkBorder, checkGesture, checkHandle, checkMirrored, computeSize, computeTabGroup, computeTabRoot, defaultFont, defaultForeground, deregister, destroyWidget, dragDetect, dragDetect, dragDetect, drawBackground, drawBackground, drawBackground, drawImageBackground, drawThemeBackground, enableDrag, enableWidget, fillBackground, fillImageBackground, fillThemeBackground, findBackgroundControl, findBrush, findCursor, findImageControl, findMnemonic, findThemeControl, fixFocus, forceFocus, forceResize, getAccessible, getBackground, getBackgroundImage, getBackgroundPixel, getBorderWidth, getBounds, getClipboardText, getCodePage, getCursor, getDragDetect, getDrawing, getEnabled, getFont, getForeground, getForegroundPixel, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getPath, getRegion, getShell, getSize, getToolTipText, getTouchEnabled, getVisible, hasCursor, hasFocus, internal_dispose_GC, internal_new_GC, isActive, isEnabled, isFocusAncestor, isFocusControl, isReparentable, isShowing, isTabGroup, isTabItem, isVisible, mapEvent, menuShell, mnemonicHit, mnemonicMatch, moveAbove, moveBelow, new_Accessible, new_GC, pack, pack, print, printWidget, redraw, redraw, redraw, register, releaseHandle, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, sendFocusEvent, sendGestureEvent, sendMove, sendTouchEvent, setBackground, setBackground, setBackgroundImage, setBackgroundImage, setBackgroundPixel, setBounds, setBounds, setBounds, setCapture, setCursor, setCursor, setDefaultFont, setDragDetect, setEnabled, setFont, setForeground, setForegroundPixel, setLayoutData, setLocation, setLocation, setMenu, setParent, setRadioFocus, setRadioSelection, setRedraw, setRegion, setSavedFocus, setSize, setSize, setTabItemFocus, setToolTipText, setToolTipText, setTouchEnabled, setVisible, showWidget, sort, subclass, toControl, toControl, toDisplay, toDisplay, topHandle, translateAccelerator, translateMnemonic, traverse, traverse, traverse, traverse, traverse, traverseEscape, traverseGroup, traverseItem, traverseMnemonic, traversePage, traverseReturn, unsubclass, update, update, updateImages, widgetCreateStruct, widgetParent, windowProc, WM_ACTIVATE, WM_CAPTURECHANGED, WM_CHANGEUISTATE, WM_CLEAR, WM_CLOSE, WM_COMMAND, WM_CONTEXTMENU, WM_CTLCOLOR, WM_CUT, WM_DESTROY, WM_DRAWITEM, WM_ENDSESSION, WM_ENTERIDLE, WM_GESTURE, WM_GETMINMAXINFO, WM_GETOBJECT, WM_HELP, WM_HOTKEY, WM_IME_CHAR, WM_IME_COMPOSITION_START, WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION, WM_INITMENUPOPUP, WM_INPUTLANGCHANGE, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS, WM_MBUTTONDBLCLK, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MEASUREITEM, WM_MENUCHAR, WM_MENUSELECT, WM_MOUSEACTIVATE, WM_MOUSEHOVER, WM_MOUSEHWHEEL, WM_MOUSELEAVE, WM_MOUSEMOVE, WM_MOVE, WM_NCACTIVATE, WM_NCCALCSIZE, WM_NCLBUTTONDOWN, WM_NCPAINT, WM_NOTIFY, WM_PALETTECHANGED, WM_PASTE, WM_PRINT, WM_QUERYENDSESSION, WM_QUERYNEWPALETTE, WM_QUERYOPEN, WM_RBUTTONDBLCLK, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETREDRAW, WM_SETTINGCHANGE, WM_SHOWWINDOW, WM_SYSCHAR, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TABLET_FLICK, WM_TOUCH, WM_UNDO, WM_UNINITMENUPOPUP, WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING, WM_XBUTTONDBLCLK, WM_XBUTTONDOWN, WM_XBUTTONUP, wmColorChild, wmCommandChild, wmDrawChild, wmMeasureChild, wmScrollChild
_addListener, addDisposeListener, addListener, checkBits, checkOpened, checkOrientation, checkParent, checkWidget, DeferWindowPos, dispose, dragDetect, error, filters, findItem, fixMnemonic, fixMnemonic, getData, getData, getDisplay, getListeners, getName, getStyle, hooks, isDisposed, isListening, isValidSubclass, isValidThread, notifyListeners, postEvent, postEvent, release, removeDisposeListener, removeListener, removeListener, reskin, reskinWidget, sendDragEvent, sendDragEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendKeyEvent, sendKeyEvent, sendMouseEvent, sendMouseEvent, sendMouseWheelEvent, sendSelectionEvent, sendSelectionEvent, setData, setData, setInputState, setKeyState, setLocationMask, SetWindowPos, showMenu, showMenu, toString, updateMenuLocation, wmCaptureChanged, wmChar, wmContextMenu, wmIMEChar, wmKeyDown, wmKeyUp, wmKillFocus, wmLButtonDblClk, wmLButtonDown, wmLButtonUp, wmMButtonDblClk, wmMButtonDown, wmMButtonUp, wmMouseHover, wmMouseHWheel, wmMouseLeave, wmMouseMove, wmMouseWheel, wmPaint, wmPrint, wmRButtonDblClk, wmRButtonDown, wmRButtonUp, wmSetFocus, wmSysChar, wmSysKeyDown, wmSysKeyUp, wmXButtonDblClk, wmXButtonDown, wmXButtonUp
static final int MIN_YEAR
static final int MAX_YEAR
boolean doubleClick
boolean ignoreSelection
SYSTEMTIME lastSystemTime
SYSTEMTIME time
static final int DateTimeProc
static final TCHAR DateTimeClass
static final int CalendarProc
static final TCHAR CalendarClass
static final int MARGIN
static final int MAX_DIGIT
static final int MAX_DAY
static final int MAX_12HOUR
static final int MAX_24HOUR
static final int MAX_MINUTE
static final int MONTH_DAY_YEAR
static final int DAY_MONTH_YEAR
static final int YEAR_MONTH_DAY
static final char SINGLE_QUOTE
static final char DAY_FORMAT_CONSTANT
static final char MONTH_FORMAT_CONSTANT
static final char YEAR_FORMAT_CONSTANT
static final char HOURS_FORMAT_CONSTANT
static final char MINUTES_FORMAT_CONSTANT
static final char SECONDS_FORMAT_CONSTANT
static final char AMPM_FORMAT_CONSTANT
static final int[] MONTH_NAMES
public DateTime(Composite parent, int style)
The style value is either one of the style constants defined in
class SWT
which is applicable to instances of this
class, or must be built by bitwise OR'ing together
(that is, using the int
"|" operator) two or more
of those SWT
style constants. The class description
lists the style constants that are applicable to the class.
Style bits are also inherited from superclasses.
parent
- a composite control which will be the parent of the new instance (cannot be null)style
- the style of control to constructjava.lang.IllegalArgumentException
- SWTException
- SWT.DATE
,
SWT.TIME
,
SWT.CALENDAR
,
SWT.SHORT
,
SWT.MEDIUM
,
SWT.LONG
,
SWT.DROP_DOWN
,
Widget.checkSubclass()
,
Widget.getStyle()
public void addSelectionListener(SelectionListener listener)
SelectionListener
interface.
widgetSelected
is called when the user changes the control's value.
widgetDefaultSelected
is typically called when ENTER is pressed.
listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- SWTException
- SelectionListener
,
removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,
SelectionEvent
int callWindowProc(int hwnd, int msg, int wParam, int lParam)
callWindowProc
in class Scrollable
static int checkStyle(int style)
protected void checkSubclass()
Widget
The SWT class library is intended to be subclassed
only at specific, controlled points (most notably,
Composite
and Canvas
when
implementing new widgets). This method enforces this
rule unless it is overridden.
IMPORTANT: By providing an implementation of this method that allows a subclass of a class which does not normally allow subclassing to be created, the implementer agrees to be fully responsible for the fact that any such subclass will likely fail between SWT releases and will be strongly platform specific. No support is provided for user-written classes which are implemented in this fashion.
The ability to subclass outside of the allowed SWT classes is intended purely to enable those not on the SWT development team to implement patches in order to get around specific limitations in advance of when those limitations can be addressed by the team. Subclassing should not be attempted without an intimate and detailed understanding of the hierarchy.
checkSubclass
in class Composite
public Point computeSize(int wHint, int hHint, boolean changed)
Control
The preferred size of a control is the size that it would
best be displayed at. The width hint and height hint arguments
allow the caller to ask a control questions such as "Given a particular
width, how high does the control need to be to show all of the contents?"
To indicate that the caller does not wish to constrain a particular
dimension, the constant SWT.DEFAULT
is passed for the hint.
If the changed flag is true
, it indicates that the receiver's
contents have changed, therefore any caches that a layout manager
containing the control may have been keeping need to be flushed. When the
control is resized, the changed flag will be false
, so layout
manager caches can be retained.
computeSize
in class Composite
wHint
- the width hint (can be SWT.DEFAULT
)hHint
- the height hint (can be SWT.DEFAULT
)changed
- true
if the control's contents have changed, and false
otherwiseLayout
,
Control.getBorderWidth()
,
Control.getBounds()
,
Control.getSize()
,
Control.pack(boolean)
,
"computeTrim, getClientArea for controls that implement them"void createHandle()
createHandle
in class Composite
int defaultBackground()
defaultBackground
in class Control
java.lang.String getCustomShortDateFormat()
java.lang.String getCustomShortTimeFormat()
java.lang.String getTimeFormat()
public int getDay()
The first day of the month is 1, and the last day depends on the month and year.
SWTException
- public int getHours()
Hours is an integer between 0 and 23.
SWTException
- public int getMinutes()
Minutes is an integer between 0 and 59.
SWTException
- public int getMonth()
The first month of the year is 0, and the last month is 11.
SWTException
- java.lang.String getNameText()
getNameText
in class Widget
public int getSeconds()
Seconds is an integer between 0 and 59.
SWTException
- public int getYear()
The first year is 1752 and the last year is 9999.
SWTException
- void releaseWidget()
releaseWidget
in class Composite
public void removeSelectionListener(SelectionListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- SWTException
- SelectionListener
,
addSelectionListener(org.eclipse.swt.events.SelectionListener)
public void setDate(int year, int month, int day)
This is the recommended way to set the date, because setting the year, month, and day separately may result in invalid intermediate dates.
year
- an integer between 1752 and 9999month
- an integer between 0 and 11day
- a positive integer beginning with 1SWTException
- public void setDay(int day)
The first day of the month is 1, and the last day depends on the month and year. If the specified day is not valid for the receiver's month and year, then it is ignored.
day
- a positive integer beginning with 1SWTException
- setDate(int, int, int)
public void setHours(int hours)
Hours is an integer between 0 and 23.
hours
- an integer between 0 and 23SWTException
- public void setMinutes(int minutes)
Minutes is an integer between 0 and 59.
minutes
- an integer between 0 and 59SWTException
- public void setMonth(int month)
The first month of the year is 0, and the last month is 11. If the specified month is not valid for the receiver's day and year, then it is ignored.
month
- an integer between 0 and 11SWTException
- setDate(int, int, int)
public void setOrientation(int orientation)
Control
SWT.LEFT_TO_RIGHT
or SWT.RIGHT_TO_LEFT
.
setOrientation
in class Control
orientation
- new orientation stylepublic void setSeconds(int seconds)
Seconds is an integer between 0 and 59.
seconds
- an integer between 0 and 59SWTException
- public void setTime(int hours, int minutes, int seconds)
hours
- an integer between 0 and 23minutes
- an integer between 0 and 59seconds
- an integer between 0 and 59SWTException
- public void setYear(int year)
The first year is 1752 and the last year is 9999. If the specified year is not valid for the receiver's day and month, then it is ignored.
year
- an integer between 1752 and 9999SWTException
- setDate(int, int, int)
int widgetStyle()
widgetStyle
in class Composite
TCHAR windowClass()
windowClass
in class Scrollable
int windowProc()
windowProc
in class Scrollable
LRESULT wmNotifyChild(NMHDR hdr, int wParam, int lParam)
wmNotifyChild
in class Control
LRESULT WM_LBUTTONDBLCLK(int wParam, int lParam)
WM_LBUTTONDBLCLK
in class Control
LRESULT WM_LBUTTONDOWN(int wParam, int lParam)
WM_LBUTTONDOWN
in class Composite
LRESULT WM_LBUTTONUP(int wParam, int lParam)
WM_LBUTTONUP
in class Control