comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet147.d @ 112:9f4c18c268b2

Update to compile and execute with dmd 2.052.
author kntroh
date Wed, 16 Mar 2011 21:53:53 +0900
parents 69b1fa94a4a8
children 536e43f63c81
comparison
equal deleted inserted replaced
111:b6e9904989ed 112:9f4c18c268b2
27 import org.eclipse.swt.widgets.Combo; 27 import org.eclipse.swt.widgets.Combo;
28 import org.eclipse.swt.widgets.Display; 28 import org.eclipse.swt.widgets.Display;
29 import org.eclipse.swt.widgets.Shell; 29 import org.eclipse.swt.widgets.Shell;
30 import java.lang.all; 30 import java.lang.all;
31 31
32 import tango.io.Stdout; 32 version(Tango){
33 import tango.io.Stdout;
34 } else { // Phobos
35 import std.stdio;
36 }
33 37
34 void main(String[] args) { 38 void main(String[] args) {
35 Display display = new Display(); 39 Display display = new Display();
36 Shell shell = new Shell(display); 40 Shell shell = new Shell(display);
37 shell.setLayout(new GridLayout()); 41 shell.setLayout(new GridLayout());
38 Combo combo = new Combo(shell, SWT.NONE); 42 Combo combo = new Combo(shell, SWT.NONE);
39 combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 43 combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
40 combo.setText("Here is some text"); 44 combo.setText("Here is some text");
41 combo.addSelectionListener(new class() SelectionAdapter{ 45 combo.addSelectionListener(new class() SelectionAdapter{
42 public void widgetDefaultSelected(SelectionEvent e) { 46 public void widgetDefaultSelected(SelectionEvent e) {
43 Stdout("Combo default selected (overrides default button)\n"); 47 version(Tango){
48 Stdout("Combo default selected (overrides default button)\n");
49 } else { // Phobos
50 writeln("Combo default selected (overrides default button)");
51 }
44 } 52 }
45 }); 53 });
46 combo.addTraverseListener(new class() TraverseListener{ 54 combo.addTraverseListener(new class() TraverseListener{
47 public void keyTraversed(TraverseEvent e) { 55 public void keyTraversed(TraverseEvent e) {
48 if (e.detail == SWT.TRAVERSE_RETURN) { 56 if (e.detail == SWT.TRAVERSE_RETURN) {
53 }); 61 });
54 Button button = new Button(shell, SWT.PUSH); 62 Button button = new Button(shell, SWT.PUSH);
55 button.setText("Ok"); 63 button.setText("Ok");
56 button.addSelectionListener(new class() SelectionAdapter{ 64 button.addSelectionListener(new class() SelectionAdapter{
57 public void widgetSelected(SelectionEvent e) { 65 public void widgetSelected(SelectionEvent e) {
58 Stdout("Button selected\n"); 66 version(Tango){
67 Stdout("Button selected\n");
68 } else { // Phobos
69 writeln("Button selected");
70 }
59 } 71 }
60 }); 72 });
61 shell.setDefaultButton(button); 73 shell.setDefaultButton(button);
62 shell.pack(); 74 shell.pack();
63 shell.open(); 75 shell.open();