Mercurial > projects > dwt-samples
diff 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 |
line wrap: on
line diff
--- a/snippets/button/Snippet108.d Sat Jul 12 17:54:42 2008 +0200 +++ b/snippets/button/Snippet108.d Sat Jul 12 20:09:06 2008 +0200 @@ -32,39 +32,40 @@ import tango.io.Stdout; void main(String[] args){ - Snippet108.main(args); + Snippet108.main(args); } public class Snippet108 { - public static void main (String [] args) { - Display display = new Display (); - Shell shell = new Shell (display); - Label label = new Label (shell, DWT.NONE); - label.setText ("Enter your name:"); - Text text = new Text (shell, DWT.BORDER); - text.setLayoutData (new RowData (100, DWT.DEFAULT)); - Button ok = new Button (shell, DWT.PUSH); - ok.setText ("OK"); - ok.addSelectionListener(new class() SelectionAdapter { - public void widgetSelected(SelectionEvent e) { - Stdout.formatln("OK"); - } - }); - Button cancel = new Button (shell, DWT.PUSH); - cancel.setText ("Cancel"); - cancel.addSelectionListener(new class() SelectionAdapter { - public void widgetSelected(SelectionEvent e) { - Stdout.formatln("Cancel"); - } - }); - shell.setDefaultButton (cancel); - shell.setLayout (new RowLayout ()); - shell.pack (); - shell.open (); - while (!shell.isDisposed ()) { - if (!display.readAndDispatch ()) display.sleep (); + public static void main (String [] args) { + Display display = new Display (); + Shell shell = new Shell (display); + Label label = new Label (shell, DWT.NONE); + label.setText ("Enter your name:"); + Text text = new Text (shell, DWT.BORDER); + text.setLayoutData (new RowData (100, DWT.DEFAULT)); + Button ok = new Button (shell, DWT.PUSH); + ok.setText ("OK"); + ok.addSelectionListener(new class() SelectionAdapter { + public void widgetSelected(SelectionEvent e) { + Stdout.formatln("OK"); + } + }); + Button cancel = new Button (shell, DWT.PUSH); + cancel.setText ("Cancel"); + cancel.addSelectionListener(new class() SelectionAdapter { + public void widgetSelected(SelectionEvent e) { + Stdout.formatln("Cancel"); + } + }); + shell.setDefaultButton (cancel); + shell.setLayout (new RowLayout ()); + shell.pack (); + shell.open (); + while (!shell.isDisposed ()) { + if (!display.readAndDispatch ()) display.sleep (); + } + display.dispose (); } - display.dispose (); - } } +