Mercurial > projects > dwt-samples
comparison snippets/composite/Snippet237.d @ 119:9a1be6ff19a2
More snippets, thanks to Tom D.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 20 Jul 2008 15:26:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
118:7b1c122b4128 | 119:9a1be6ff19a2 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2006 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * D Port: | |
11 * Thomas Demmer <t_demmer AT web DOT de> | |
12 *******************************************************************************/ | |
13 module composite.Snippet237; | |
14 /* | |
15 * Composite Snippet: inherit a background color or image | |
16 * | |
17 * For a list of all SWT example snippets see | |
18 * http://www.eclipse.org/swt/snippets/ | |
19 * | |
20 * @since 3.2 | |
21 */ | |
22 | |
23 import dwt.DWT; | |
24 import dwt.graphics.Color; | |
25 import dwt.layout.RowLayout; | |
26 import dwt.widgets.Display; | |
27 import dwt.widgets.Button; | |
28 import dwt.widgets.Composite; | |
29 import dwt.widgets.Group; | |
30 import dwt.widgets.Label; | |
31 import dwt.widgets.List; | |
32 import dwt.widgets.Shell; | |
33 import dwt.widgets.Text; | |
34 | |
35 import dwt.dwthelper.utils; | |
36 | |
37 void main(String[] args){ | |
38 Snippet237.main(args); | |
39 } | |
40 public class Snippet237 { | |
41 | |
42 public static void main(String[] args) { | |
43 Display display = new Display(); | |
44 Shell shell = new Shell(display); | |
45 shell.setText("Composite.setBackgroundMode()"); | |
46 shell.setLayout(new RowLayout(DWT.VERTICAL)); | |
47 | |
48 Color color = display.getSystemColor(DWT.COLOR_CYAN); | |
49 | |
50 Group group = new Group(shell, DWT.NONE); | |
51 group.setText("DWT.INHERIT_NONE"); | |
52 group.setBackground(color); | |
53 group.setBackgroundMode(DWT.INHERIT_NONE); | |
54 createChildren(group); | |
55 | |
56 group = new Group(shell, DWT.NONE); | |
57 group.setBackground(color); | |
58 group.setText("DWT.INHERIT_DEFAULT"); | |
59 group.setBackgroundMode(DWT.INHERIT_DEFAULT); | |
60 createChildren(group); | |
61 | |
62 group = new Group(shell, DWT.NONE); | |
63 group.setBackground(color); | |
64 group.setText("DWT.INHERIT_FORCE"); | |
65 group.setBackgroundMode(DWT.INHERIT_FORCE); | |
66 createChildren(group); | |
67 | |
68 shell.pack(); | |
69 shell.open(); | |
70 while(!shell.isDisposed()) { | |
71 if(!display.readAndDispatch()) display.sleep(); | |
72 } | |
73 display.dispose(); | |
74 } | |
75 static void createChildren(Composite parent) { | |
76 parent.setLayout(new RowLayout()); | |
77 List list = new List(parent, DWT.BORDER | DWT.MULTI); | |
78 list.add("List item 1"); | |
79 list.add("List item 2"); | |
80 Label label = new Label(parent, DWT.NONE); | |
81 label.setText("Label"); | |
82 Button button = new Button(parent, DWT.RADIO); | |
83 button.setText("Radio Button"); | |
84 button = new Button(parent, DWT.CHECK); | |
85 button.setText("Check box Button"); | |
86 button = new Button(parent, DWT.PUSH); | |
87 button.setText("Push Button"); | |
88 Text text = new Text(parent, DWT.BORDER); | |
89 text.setText("Text"); | |
90 } | |
91 } |