SWT Shell

31 December 2007

Shell represent the “windows” which the desktop or “window manager” is managing. Instances that do not have a parent (that is, they are built using the constructor, which takes a Display as the argument) are described as top level shells. Instances that do have a parent are described as secondary or dialog shells.

Instances are always displayed in one of the maximized, minimized or normal states:

- When an instance is marked as maximized, the window manager will typically resize it to fill the entire visible area of the display, and the instance is usually put in a state where it can not be resized (even if it has style RESIZE) until it is no longer maximized.

- When an instance is in the normal state (neither maximized or minimized), its appearance is controlled by the style constants which were specified when it was created and the restrictions of the window manager.

- When an instance has been marked as minimized, its contents (client area) will usually not be visible, and depending on the window manager, it may be “iconified” (that is, replaced on the desktop by a small simplified representation of itself), relocated to a distinguished area of the screen, or hidden. Combinations of these changes are also possible.

Please note that the styles supported by this class must be treated as HINTs, since the window manager for the desktop on which the instance is visible has ultimate control over the appearance and behavior of decorations and modality. For example, some window managers only support resizable windows and will always assume the RESIZE style, even if it is not set. In addition, if a modality style is not supported, it is “upgraded” to a more restrictive modality style that is supported. For example, if PRIMARY_MODAL is not supported, it would be upgraded to APPLICATION_MODAL.

Shell supports following Styles: BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL, APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL. Events supported by Shell areActivate, Close, Deactivate, Deiconify, Iconify.

Please also note that only one of the styles APPLICATION_MODAL, MODELESS, PRIMARY_MODAL and SYSTEM_MODAL may be specified.

Example

The example below creates two windows, one within another. Shell creates window `Shell`, and within that window Shell `Dialog`. Method setText() is used to set title of Shell while setSize() is used to set Shell Size.

import org.eclipse.swt.widgets.*;
 
public class SWTShell {
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setText("Shell");
		shell.setSize(200, 200);
		shell.open();
		Shell dialog = new Shell(shell);
		dialog.setText("Dialog");
		dialog.setSize(200, 200);
		dialog.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
 
}

Output:
SWThell

del.icio.us:SWT Shell  digg:SWT Shell  spurl:SWT Shell  wists:SWT Shell  simpy:SWT Shell  newsvine:SWT Shell  blinklist:SWT Shell  furl:SWT Shell  reddit:SWT Shell  fark:SWT Shell  blogmarks:SWT Shell  Y!:SWT Shell  smarking:SWT Shell  magnolia:SWT Shell  segnalo:SWT Shell  gifttagging:SWT Shell

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: SWT Shell

Leave a Reply