comparison snippets/button/Snippet108.d @ 117:8cdaac0dc743

Added more snippets from TomD
author Frank Benoit <benoit@tionex.de>
date Sat, 12 Jul 2008 20:09:06 +0200
parents 0de3dab4d6e1
children
comparison
equal deleted inserted replaced
116:f53c6274734f 117:8cdaac0dc743
30 30
31 import dwt.dwthelper.utils; 31 import dwt.dwthelper.utils;
32 import tango.io.Stdout; 32 import tango.io.Stdout;
33 33
34 void main(String[] args){ 34 void main(String[] args){
35 Snippet108.main(args); 35 Snippet108.main(args);
36 } 36 }
37 37
38 public class Snippet108 { 38 public class Snippet108 {
39 39
40 public static void main (String [] args) { 40 public static void main (String [] args) {
41 Display display = new Display (); 41 Display display = new Display ();
42 Shell shell = new Shell (display); 42 Shell shell = new Shell (display);
43 Label label = new Label (shell, DWT.NONE); 43 Label label = new Label (shell, DWT.NONE);
44 label.setText ("Enter your name:"); 44 label.setText ("Enter your name:");
45 Text text = new Text (shell, DWT.BORDER); 45 Text text = new Text (shell, DWT.BORDER);
46 text.setLayoutData (new RowData (100, DWT.DEFAULT)); 46 text.setLayoutData (new RowData (100, DWT.DEFAULT));
47 Button ok = new Button (shell, DWT.PUSH); 47 Button ok = new Button (shell, DWT.PUSH);
48 ok.setText ("OK"); 48 ok.setText ("OK");
49 ok.addSelectionListener(new class() SelectionAdapter { 49 ok.addSelectionListener(new class() SelectionAdapter {
50 public void widgetSelected(SelectionEvent e) { 50 public void widgetSelected(SelectionEvent e) {
51 Stdout.formatln("OK"); 51 Stdout.formatln("OK");
52 } 52 }
53 }); 53 });
54 Button cancel = new Button (shell, DWT.PUSH); 54 Button cancel = new Button (shell, DWT.PUSH);
55 cancel.setText ("Cancel"); 55 cancel.setText ("Cancel");
56 cancel.addSelectionListener(new class() SelectionAdapter { 56 cancel.addSelectionListener(new class() SelectionAdapter {
57 public void widgetSelected(SelectionEvent e) { 57 public void widgetSelected(SelectionEvent e) {
58 Stdout.formatln("Cancel"); 58 Stdout.formatln("Cancel");
59 } 59 }
60 }); 60 });
61 shell.setDefaultButton (cancel); 61 shell.setDefaultButton (cancel);
62 shell.setLayout (new RowLayout ()); 62 shell.setLayout (new RowLayout ());
63 shell.pack (); 63 shell.pack ();
64 shell.open (); 64 shell.open ();
65 while (!shell.isDisposed ()) { 65 while (!shell.isDisposed ()) {
66 if (!display.readAndDispatch ()) display.sleep (); 66 if (!display.readAndDispatch ()) display.sleep ();
67 }
68 display.dispose ();
67 } 69 }
68 display.dispose ();
69 }
70 } 70 }
71