28
|
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 org.eclipse.swt.snippets.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 org.eclipse.swt.SWT;
|
|
24 import org.eclipse.swt.graphics.Color;
|
|
25 import org.eclipse.swt.layout.RowLayout;
|
|
26 import org.eclipse.swt.widgets.Display;
|
|
27 import org.eclipse.swt.widgets.Button;
|
|
28 import org.eclipse.swt.widgets.Composite;
|
|
29 import org.eclipse.swt.widgets.Group;
|
|
30 import org.eclipse.swt.widgets.Label;
|
|
31 import org.eclipse.swt.widgets.List;
|
|
32 import org.eclipse.swt.widgets.Shell;
|
|
33 import org.eclipse.swt.widgets.Text;
|
|
34
|
|
35 import java.lang.all;
|
|
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(SWT.VERTICAL));
|
|
47
|
|
48 Color color = display.getSystemColor(SWT.COLOR_CYAN);
|
|
49
|
|
50 Group group = new Group(shell, SWT.NONE);
|
|
51 group.setText("SWT.INHERIT_NONE");
|
|
52 group.setBackground(color);
|
|
53 group.setBackgroundMode(SWT.INHERIT_NONE);
|
|
54 createChildren(group);
|
|
55
|
|
56 group = new Group(shell, SWT.NONE);
|
|
57 group.setBackground(color);
|
|
58 group.setText("SWT.INHERIT_DEFAULT");
|
|
59 group.setBackgroundMode(SWT.INHERIT_DEFAULT);
|
|
60 createChildren(group);
|
|
61
|
|
62 group = new Group(shell, SWT.NONE);
|
|
63 group.setBackground(color);
|
|
64 group.setText("SWT.INHERIT_FORCE");
|
|
65 group.setBackgroundMode(SWT.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, SWT.BORDER | DWT.MULTI);
|
|
78 list.add("List item 1");
|
|
79 list.add("List item 2");
|
|
80 Label label = new Label(parent, SWT.NONE);
|
|
81 label.setText("Label");
|
|
82 Button button = new Button(parent, SWT.RADIO);
|
|
83 button.setText("Radio Button");
|
|
84 button = new Button(parent, SWT.CHECK);
|
|
85 button.setText("Check box Button");
|
|
86 button = new Button(parent, SWT.PUSH);
|
|
87 button.setText("Push Button");
|
|
88 Text text = new Text(parent, SWT.BORDER);
|
|
89 text.setText("Text");
|
|
90 }
|
|
91 }
|