Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod2006-12-12 14:04:53 -0500
committerCarolyn MacLeod2006-12-12 14:04:53 -0500
commitc40be34806a07a7e02209f4d38b2fe1e33df8ea4 (patch)
tree0fa46d991efcedf29462e23bbe7c14e891e7e3f0
parentfc48378e9f0f4b0897a68c392d2c3184541abb46 (diff)
downloadeclipse.platform.swt-c40be34806a07a7e02209f4d38b2fe1e33df8ea4.tar.gz
eclipse.platform.swt-c40be34806a07a7e02209f4d38b2fe1e33df8ea4.tar.xz
eclipse.platform.swt-c40be34806a07a7e02209f4d38b2fe1e33df8ea4.zip
*** empty log message ***
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet251.java48
1 files changed, 28 insertions, 20 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet251.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet251.java
index ac9bfdd8bd..0e7ca0b823 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet251.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet251.java
@@ -11,7 +11,7 @@
package org.eclipse.swt.snippets;
/*
- * DateTime example snippet: create a DateTime calendar and a DateTime time in a dialog.
+ * DateTime example snippet: create a DateTime calendar, date, and time in a dialog.
*
* For a list of all SWT example snippets see
* http://www.eclipse.org/swt/snippets/
@@ -25,33 +25,41 @@ public class Snippet251 {
public static void main (String [] args) {
Display display = new Display ();
- Shell shell = new Shell (display);
+ final Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
- final Shell dialog = new Shell (shell, SWT.DIALOG_TRIM);
- dialog.setLayout (new GridLayout (2, false));
+ Button open = new Button (shell, SWT.PUSH);
+ open.setText ("Open Dialog");
+ open.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ final Shell dialog = new Shell (shell, SWT.DIALOG_TRIM);
+ dialog.setLayout (new GridLayout (3, false));
- final DateTime calendar = new DateTime (dialog, SWT.CALENDAR | SWT.BORDER);
- final DateTime time = new DateTime (dialog, SWT.TIME | SWT.SHORT);
+ final DateTime calendar = new DateTime (dialog, SWT.CALENDAR | SWT.BORDER);
+ final DateTime date = new DateTime (dialog, SWT.DATE | SWT.SHORT);
+ final DateTime time = new DateTime (dialog, SWT.TIME | SWT.SHORT);
- new Label (dialog, SWT.NONE);
- Button ok = new Button (dialog, SWT.PUSH);
- ok.setText ("OK");
- ok.setLayoutData(new GridData (SWT.FILL, SWT.CENTER, false, false));
- ok.addSelectionListener (new SelectionAdapter () {
- public void widgetSelected (SelectionEvent e) {
- System.out.println ("Date selected (MM/DD/YYYY) = " + (calendar.getMonth () + 1) + "/" + calendar.getDay () + "/" + calendar.getYear ());
- System.out.println ("Time selected (HH:MM) = " + time.getHours () + ":" + time.getMinutes ());
- dialog.close ();
+ new Label (dialog, SWT.NONE);
+ new Label (dialog, SWT.NONE);
+ Button ok = new Button (dialog, SWT.PUSH);
+ ok.setText ("OK");
+ ok.setLayoutData(new GridData (SWT.FILL, SWT.CENTER, false, false));
+ ok.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ System.out.println ("Calendar date selected (MM/DD/YYYY) = " + (calendar.getMonth () + 1) + "/" + calendar.getDay () + "/" + calendar.getYear ());
+ System.out.println ("Date selected (MM/YYYY) = " + (date.getMonth () + 1) + "/" + date.getYear ());
+ System.out.println ("Time selected (HH:MM) = " + time.getHours () + ":" + time.getMinutes ());
+ dialog.close ();
+ }
+ });
+ dialog.setDefaultButton (ok);
+ dialog.pack ();
+ dialog.open ();
}
});
- dialog.setDefaultButton (ok);
-
shell.pack ();
shell.open ();
- dialog.pack ();
- dialog.open ();
-
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}

Back to the top