-
Notifications
You must be signed in to change notification settings - Fork 5
DateTime Tutorial
Jin Liu edited this page Mar 24, 2015
·
6 revisions
DateTime是用来显示与时间相关的如年月日,时分秒的组件。它相对比较简单,我们通过一个示例来完整的学习它:
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("DateTime Tutorial");
shell.setLayout(new GridLayout(2, false));
new Label(shell, SWT.NONE).setText("Date: ");
new DateTime(shell, SWT.DATE);
new Label(shell, SWT.NONE).setText("Date(Long): ");
new DateTime(shell, SWT.DATE | SWT.LONG);
new Label(shell, SWT.NONE).setText("Date(Medium): ");
new DateTime(shell, SWT.DATE | SWT.MEDIUM);
new Label(shell, SWT.NONE).setText("Date(Short): ");
new DateTime(shell, SWT.DATE | SWT.SHORT);
new Label(shell, SWT.NONE).setText("Date(Drop Down): ");
new DateTime(shell, SWT.DATE | SWT.DROP_DOWN);
new Label(shell, SWT.NONE).setText("Time: ");
new DateTime(shell, SWT.TIME);
new Label(shell, SWT.NONE).setText("Time(Short): ");
new DateTime(shell, SWT.TIME | SWT.SHORT);
new Label(shell, SWT.NONE).setText("Calendar: ");
new DateTime(shell, SWT.CALENDAR);
shell.open();
shell.pack();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
效果如图:

1. DefaultSelection:按下回车键(Enter)时触发。
2. Selection:Date或Time发生改变时触发。
参考资料:
- DateTime snippets
- 如果想了解更多的关于设置颜色,字体等其它属性的相关内容,请移步至控件的通用设置。
- 如果想了解更多的关于
Layout和LayoutData的相关内容,请移步至布局管理器。 - SWT Example: ControlExample
- Sample code and further information
上一篇:Spinner Tutorial 下一篇:Table Tutorial
Soyatec Eclipse Plug-in and RCP Tutorials, wrote by Jin Liu (jin.liu@soyatec.com).
Eclipse Plug-in Development Tutorial
-
Standard Widget Toolkit Tutorial
-
Widgets Tutorial
- Label Tutorial
- Button Tutorial
- Text Tutorial
- Combo Tutorial
- List Tutorial
- Scale Tutorial
- Slider Tutorial
- Spinner Tutorial
- DateTime Tutorial
- Table Tutorial
- Tree Tutorial
- ToolBar Tutorial
- CoolBar Tutorial
- ProgressBar Tutorial
- ScrollBar Tutorial
- TaskBar Tutorial
- ExpandBar Tutorial
- Menu Tutorial
- Sash Tutorial
- ToolTip Tutorial
- Tray Tutorial
- Link Tutorial
- Browser Tutorial
- Dialog Tutorial
- Common Properties Tutorial
- Components Tutorial
- Shell Tutorial
- Display Tutorial
- SWT Custom Widgets Tutorial
- Drag and Drop Tutorial
- Layouts Tutorial
- Resource Management Tutorial
-
Widgets Tutorial
-
[JFace Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/JFace-Tutorial)
- [JFace Viewers Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/JFace-Viewers-Tutorial)
- [TableViewer Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/TableViewer-Tutorial)
- [TreeViewer Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/TreeViewer-Tutorial)
- [ListViewer Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/ListViewer-Tutorial)
- [ComboViewer Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/ComboViewer-Tutorial)
- [JFace Dialogs Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/JFace-Dialogs-Tutorial)
- [JFace DataBinding Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/JFace-DataBinding-Tutorial)
- [JFace Viewers Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/JFace-Viewers-Tutorial)
-
[Plug-in Development Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Plug-in-Development-Tutorial)
- [Views Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Views-Tutorial)
- [Editors Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Editors-Tutorial)
- [Action and Menus Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Action-and-Menus-Tutorial)
- [Preferences Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Preferences-Tutorial)
- [ExtensionPoint Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/ExtensionPoint-Tutorial)
- [Publish Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Publish-Tutorial)
- [Feature Project Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Feature-Project-Tutorial)
- [UpdateSite Project Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/UpdateSite-Project-Tutorial)
- [Fragment Project Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Fragment-Project-Tutorial)
-
[Eclipse 3.x RCP Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Eclipse-3.x-RCP-Tutorial)
- [Branding Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Branding-Tutorial)
- [Publish RCP Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/Publish-RCP-Tutorial)
-
[Graphical Editing Framework Tutorial] (https://github.com/ecsoya/eclipse.tutorial/wiki/GEF-Tutorial)