Top Description Fields Constructors Methods
org.eclipse.swt.widgets

public Class Shell

extends Decorations
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.cairo.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*

Instances of this class 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:

The modality of an instance may be specified using style bits. The modality style bits are used to determine whether input is blocked for other shells on the display. The PRIMARY_MODAL style allows an instance to block input to its parent. The APPLICATION_MODAL style allows an instance to block input to every other shell in the display. The SYSTEM_MODAL style allows an instance to block input to all shells, including shells belonging to different applications.

Note

The styles supported by this class are 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. A modality style may also be "downgraded" to a less restrictive style. For example, most operating systems no longer support SYSTEM_MODAL because it can freeze up the desktop, so this is typically downgraded to APPLICATION_MODAL.

Styles:
BORDER, CLOSE, MIN, MAX, NO_MOVE, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL, SHEET
APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL
Events:
Activate, Close, Deactivate, Deiconify, Iconify

Class SWT provides two "convenience constants" for the most commonly required style combinations:

SHELL_TRIM
the result of combining the constants which are required to produce a typical application top level shell: (that is, CLOSE | TITLE | MIN | MAX | RESIZE)
DIALOG_TRIM
the result of combining the constants which are required to produce a typical application dialog shell: (that is, TITLE | CLOSE | BORDER)

Note

Only one of the styles APPLICATION_MODAL, MODELESS, PRIMARY_MODAL and SYSTEM_MODAL may be specified.

Important Note

This class is not intended to be subclassed.

See Also
Decorations, SWT, Shell snippets, SWT Example: ControlExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv boolean
pack-priv boolean
pack-priv GeometryInterface
pack-priv boolean
pack-priv long
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv Control
pack-priv boolean
pack-priv static final int
pack-priv long
pack-priv boolean
pack-priv boolean
pack-priv int
pack-priv int
pack-priv int
pack-priv int
pack-priv boolean
pack-priv Region
pack-priv boolean
pack-priv static final double
pack-priv long
pack-priv boolean
pack-priv ToolTip[]
pack-priv long
pack-priv long
Inherited from org.eclipse.swt.widgets.Decorations:
accelGroupdefaultButtonimageimagesmaximizedmenuBarmenusminimizedsaveDefaultsavedFocustextvboxHandle

Constructor Summary

AccessConstructor and Description
public
Shell()

Constructs a new instance of this class.

public
Shell(int
the style of control to construct
style
)

Constructs a new instance of this class given only the style value describing its behavior and appearance.

public
Shell(Display
the display to create the shell on
display
)

Constructs a new instance of this class given only the display to create it on.

public
Shell(Display
the display to create the shell on
display
,
int
the style of control to construct
style
)

Constructs a new instance of this class given the display to create it on and a style value describing its behavior and appearance.

pack-priv
Shell(Display display, Shell parent, int style, long handle, boolean embedded)

public
Shell(Shell
a shell which will be the parent of the new instance
parent
)

Constructs a new instance of this class given only its parent.

public
Shell(Shell
a shell which will be the parent of the new instance
parent
,
int
the style of control to construct
style
)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Method Summary

Modifier and TypeMethod and Description
pack-priv Shell
public void
addShellListener(ShellListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when operations are performed on the receiver, by sending the listener one of the messages defined in the ShellListener interface.

pack-priv void
pack-priv void
pack-priv void
bringToTop(boolean force)

pack-priv void
pack-priv void
checkAndUngrabFocus()

SWT.ON_TOP shells on Wayland requires gdk_seat_grab to grab keyboard/input focus, the grabbed focus need to be removed when Shell is disposed/hidden.

pack-priv void
pack-priv void
pack-priv static int
checkStyle(Shell parent, int style)

public void
close()

Requests that the window manager close the receiver in the same way it would be closed when the user clicks on the "close box" or performs some other platform specific key or mouse combination that indicates the window should be removed.

pack-priv void
pack-priv Rectangle
computeTrimInPixels(int x, int y, int width, int height)

Overrides org.eclipse.swt.widgets.Scrollable.computeTrimInPixels.

pack-priv void
pack-priv void
public void
dispose()

Overrides org.eclipse.swt.widgets.Widget.dispose.

Disposes of the operating system resources associated with the receiver and all its descendants.
pack-priv long
filterProc(long xEvent, long gdkEvent, long data2)

Overrides org.eclipse.swt.widgets.Widget.filterProc.

pack-priv Control
pack-priv Composite
pack-priv void
pack-priv void
fixShell(Shell newShell, Control control)

pack-priv void
public void
forceActive()

If the receiver is visible, moves it to the top of the drawing order for the display on which it was created (so that all other shells on that display, which are not the receiver's children will be drawn behind it) and forces the window manager to make the shell active.

pack-priv void
pack-priv void
forceResize(int width, int height)

pack-priv static void
gdk_region_get_rectangles(long region, long[] rectangles, int[] n_rectangles)

public int

Returns:

the alpha value
getAlpha
()

Returns the receiver's alpha value.

pack-priv Rectangle
public boolean

Returns:

the fullscreen state
getFullScreen
()

Returns true if the receiver is currently in fullscreen state, and false otherwise.

public int

Returns:

the IME mode
getImeInputMode
()

Returns the receiver's input method editor mode.

pack-priv Point
public boolean
getMaximized()

Overrides org.eclipse.swt.widgets.Decorations.getMaximized.

Returns true if the receiver is currently maximized, and false otherwise.
public Point

Returns:

the receiver's size
getMaximumSize
()

Returns a point describing the maximum receiver's size.

pack-priv Point
public Point

Returns:

the receiver's size
getMinimumSize
()

Returns a point describing the minimum receiver's size.

pack-priv Point
pack-priv Shell
public boolean

Returns:

true if the receiver is marked as modified, or false otherwise
getModified
()

Gets the receiver's modified state.

public Region

Returns:

the region that defines the shape of the shell, or null
getRegion
()

Overrides org.eclipse.swt.widgets.Control.getRegion.

Returns the region that defines the shape of the shell, or null if the shell has the default shape.
pack-priv int
getResizeMode(double x, double y)

public Shell[]

Returns:

the dialog shells
getShells
()

Returns an array containing all shells which are descendants of the receiver.

pack-priv Point
pack-priv Point
getSurfaceOrigin()

Overrides org.eclipse.swt.widgets.Control.getSurfaceOrigin.

Gets the position of the top left corner of the control in root window (display) coordinates.
public ToolBar

Returns:

a ToolBar object representing the Shell's tool bar, or null.
getToolBar
()

Returns a ToolBar object representing the tool bar that can be shown in the receiver's trim.

public boolean
getVisible()

Overrides org.eclipse.swt.widgets.Control.getVisible.

Returns true if the receiver is visible, and false otherwise.
pack-priv Point
getWindowOrigin()

Overrides org.eclipse.swt.widgets.Control.getWindowOrigin.

Gets the position of the top left corner of the control in root window (display) coordinates.
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
gtk_draw(long widget, long cairo)

Overrides org.eclipse.swt.widgets.Canvas.gtk_draw.

pack-priv long
pack-priv long
gtk_focus(long widget, long directionType)

Overrides org.eclipse.swt.widgets.Composite.gtk_focus.

pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
gtk_move_focus(long widget, long directionType)

Overrides org.eclipse.swt.widgets.Widget.gtk_move_focus.

public static Shell

Returns:

a new shell object containing the specified display and handle
gtk_new
(Display
the display for the shell
display
,
long
the handle for the shell
handle
)

Invokes platform specific functionality to allocate a new shell that is embedded.

pack-priv long
pack-priv long
pack-priv long
pack-priv boolean
pack-priv void
public static Shell

Returns:

a new shell object containing the specified display and handle
internal_new
(Display
the display for the shell
display
,
long
the handle for the shell
handle
)

Invokes platform specific functionality to allocate a new shell that is not embedded.

pack-priv boolean

Returns:

true if this Shell has both SWT.RESIZE and SWT.ON_TOP set without SWT.NO_TRIM, false otherwise.
isCustomResize
()

Determines whether a Shell has both SWT.RESIZE and SWT.ON_TOP set without SWT.NO_TRIM.

public boolean
isEnabled()

Overrides org.eclipse.swt.widgets.Control.isEnabled.

Returns true if the receiver is enabled and all ancestors up to and including the receiver's nearest ancestor shell are enabled.
pack-priv boolean

Returns:

true if the parent of this Shell has style SWT.ON_TOP, false otherwise.
isMappedToPopup
()

Determines whether a Shell's parent is a popup window.

pack-priv boolean
public boolean
isVisible()

Overrides org.eclipse.swt.widgets.Control.isVisible.

Returns true if the receiver is visible and all ancestors up to and including the receiver's nearest ancestor shell are visible.
pack-priv static Region
pack-priv long
notifyState(long object, long arg0)

Overrides org.eclipse.swt.widgets.Widget.notifyState.

public void
open()

Moves the receiver to the top of the drawing order for the display on which it was created (so that all other shells on that display, which are not the receiver's children will be drawn behind it), marks it visible, sets the focus and asks the window manager to make the shell active.

pack-priv long
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
public void
removeShellListener(ShellListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when operations are performed on the receiver.

pack-priv void
public void
requestLayout()

Overrides org.eclipse.swt.widgets.Control.requestLayout.

Requests that this control and all of its ancestors be repositioned by their layouts at the earliest opportunity.
pack-priv boolean
pack-priv void
resizeBounds(int width, int height, boolean notify)

pack-priv void
public void
setActive()

If the receiver is visible, moves it to the top of the drawing order for the display on which it was created (so that all other shells on that display, which are not the receiver's children will be drawn behind it) and asks the window manager to make the shell active

pack-priv void
pack-priv void
setActiveControl(Control control, int type)

public void
setAlpha(int
the alpha value
alpha
)

Sets the receiver's alpha value which must be between 0 (transparent) and 255 (opaque).

pack-priv int
setBounds(int x, int y, int width, int height, boolean move, boolean resize)

Overrides org.eclipse.swt.widgets.Canvas.setBounds.

pack-priv void
public void
setEnabled(boolean
the new enabled state
enabled
)

Overrides org.eclipse.swt.widgets.Control.setEnabled.

Enables the receiver if the argument is true, and disables it otherwise.
public void
setFullScreen(boolean
the new fullscreen state
fullScreen
)

Sets the full screen state of the receiver.

public void
setImeInputMode(int
the new IME mode
mode
)

Sets the input method editor mode to the argument which should be the result of bitwise OR'ing together one or more of the following constants defined in class SWT: NONE, ROMAN, DBCS, PHONETIC, NATIVE, ALPHA.

pack-priv void
public void
setMaximized(boolean
the new maximized state
maximized
)

Overrides org.eclipse.swt.widgets.Decorations.setMaximized.

Sets the maximized state of the receiver.
public void
setMaximumSize(int
the new maximum width for the receiver
width
,
int
the new maximum height for the receiver
height
)

Sets the receiver's maximum size to the size specified by the arguments.

public void
setMaximumSize(Point
the new maximum size for the receiver
size
)

Sets the receiver's maximum size to the size specified by the argument.

pack-priv void
pack-priv void
setMaximumSizeInPixels(int width, int height)

public void
setMenuBar(Menu
the new menu bar
menu
)

Overrides org.eclipse.swt.widgets.Decorations.setMenuBar.

Sets the receiver's menu bar to the argument, which may be null.
public void
setMinimized(boolean
the new minimized state
minimized
)

Overrides org.eclipse.swt.widgets.Decorations.setMinimized.

Sets the minimized stated of the receiver.
public void
setMinimumSize(int
the new minimum width for the receiver
width
,
int
the new minimum height for the receiver
height
)

Sets the receiver's minimum size to the size specified by the arguments.

public void
setMinimumSize(Point
the new minimum size for the receiver
size
)

Sets the receiver's minimum size to the size specified by the argument.

pack-priv void
setMinimumSizeInPixels(int width, int height)

pack-priv void
public void
setModified(boolean
the new modified state for the receiver
modified
)

Sets the receiver's modified state as specified by the argument.

public void
setRegion(Region
the region that defines the shape of the shell (or null)
region
)

Overrides org.eclipse.swt.widgets.Control.setRegion.

Sets the shape of the shell to the region specified by the argument.
pack-priv void
public void
setText(String
the new text
string
)

Overrides org.eclipse.swt.widgets.Decorations.setText.

Sets the receiver's text, which is the string that the window manager will typically display as the receiver's title, to the argument, which must not be null.
public void
setVisible(boolean
the new visibility state
visible
)

Overrides org.eclipse.swt.widgets.Control.setVisible.

Marks the receiver as visible if the argument is true, and marks it invisible otherwise.
pack-priv void
setZOrder(Control sibling, boolean above, boolean fixRelations)

Overrides org.eclipse.swt.widgets.Control.setZOrder.

pack-priv long
shellMapProc(long handle, long arg0, long user_data)

Overrides org.eclipse.swt.widgets.Widget.shellMapProc.

pack-priv void
pack-priv long
sizeAllocateProc(long handle, long arg0, long user_data)

Overrides org.eclipse.swt.widgets.Widget.sizeAllocateProc.

pack-priv long
sizeRequestProc(long handle, long arg0, long user_data)

Overrides org.eclipse.swt.widgets.Widget.sizeRequestProc.

pack-priv long
pack-priv boolean
pack-priv int
pack-priv int
private void
updateDecorations(long gdkResource)

pack-priv void
updateMinimized(boolean minimized)

pack-priv void
Inherited from org.eclipse.swt.widgets.Decorations:
_setImagesaddMenucheckStylecheckSubclasscomparecomputeTabGroupcomputeTabRootcreateAccelGroupcreateWidgetdestroyAccelGroupfixAccelGroupfixDecorationsgetDefaultButtongetImagegetImagesgetMenuBargetMinimizedgetNameTextgetTextisReparentableisTabGroupisTabItemmenuShellremoveMenurestoreFocussetDefaultButtonsetImagesetImagessetOrientationsetSavedFocussorttraverseItemtraverseReturn