Skip to main content
summaryrefslogtreecommitdiffstats
blob: d48640a6dcddddeaafa8aac5ee70e2689de9231c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package org.eclipse.swt.examples.controlexample;

/*
 * Licensed Materials - Property of IBM,
 * WebSphere Studio Workbench
 * (c) Copyright IBM Corp 2000
 */

/* Imports */
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.*;
import java.util.ResourceBundle;

/**
* <code>ControlExample</code> is a simple demonstration
* of the controls defined by SWT.  It consists of a shell
* and tab folder where each tab in the folder allows the
* user to interact with a control.
*/
 
/* Class Definition */
public class ControlExample {
	Shell shell;
	TabFolder tabFolder;
	ResourceBundle resControls = ResourceBundle.getBundle("examples_control");
/**
* Create a new example and open it.
* 
* @param args the command line arguments
*
*/
public static void main (String[] args) {
	new ControlExample ().open ();
}
/**
* Open the example.
*/
void open () {
	
	/* Load resources */
	Images.loadImages ();

	/* Create the shell */
	shell = new Shell ();
	shell.setText (resControls.getString("Control_Example"));
	shell.addControlListener (new ControlAdapter () {
		public void controlResized (ControlEvent e) {
			tabFolder.setBounds (shell.getClientArea ());
		}
	});

	/* Create the tab folder */
	ShellTab shellTab = new ShellTab ();
	tabFolder = new TabFolder (shell, SWT.NULL);
	Tab [] tabs = new Tab [] {
		new ButtonTab (),
		new ComboTab (),
		new DialogTab (),
		new LabelTab (),
		new ListTab (),
		new ProgressBarTab (),
		new SashTab (),
		shellTab,
		new SliderTab (),
		new TableTab (),
		new TextTab (),
		new ToolBarTab (),
		new TreeTab (),
	};
	for (int i=0; i<tabs.length; i++) {
		TabItem item = new TabItem (tabFolder, SWT.NULL);
	    item.setText (tabs [i].getTabText ());
	    item.setControl (tabs [i].createTabFolderPage (tabFolder));
	}

	/* Run the event loop */
	shell.open ();
	Display display = Display.getDefault ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}

	/*
	* Destroy any shells that may have been created
	* by the Shells tab.  When a shell is disposed,
	* all child shells are also disposed.  Therefore
	* it is necessary to check for disposed shells
	* in the shells list to avoid disposing a shell
	* twice.
	*/
	shellTab.closeAllShells ();
	
	/* Free resources */
	Images.freeImages ();
}
}

Back to the top