org.eclipse.swt.widgets
Class Decorations

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.eclipse.swt.widgets.Canvas
                      extended by org.eclipse.swt.widgets.Decorations
All Implemented Interfaces:
Drawable
Direct Known Subclasses:
Shell

public class Decorations
extends Canvas

Instances of this class provide the appearance and behavior of Shells, but are not top level shells or dialogs. Class Shell shares a significant amount of code with this class, and is a subclass.

IMPORTANT: This class was intended to be abstract and should never be referenced or instantiated. Instead, the class Shell should be used.

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

Note: 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. For example, some window managers only support resizable windows and will always assume the RESIZE style, even if it is not set.
Styles:
BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP
Events:
(none)
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)

IMPORTANT: This class is intended to be subclassed only within the SWT implementation.

See Also:
getMinimized(), getMaximized(), Shell, SWT

Constructor Summary
Decorations(Composite parent, int style)
          Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 Button getDefaultButton()
          Returns the receiver's default button if one had previously been set, otherwise returns null.
 Image getImage()
          Returns the receiver's image if it had previously been set using setImage().
 boolean getMaximized()
          Returns true if the receiver is currently maximized, and false otherwise.
 Menu getMenuBar()
          Returns the receiver's menu bar if one had previously been set, otherwise returns null.
 boolean getMinimized()
          Returns true if the receiver is currently minimized, and false otherwise.
 java.lang.String getText()
          Returns the receiver's text, which is the string that the window manager will typically display as the receiver's title.
 void setDefaultButton(Button button)
          If the argument is not null, sets the receiver's default button to the argument, and if the argument is null, sets the receiver's default button to the first button which was set as the receiver's default button (called the saved default button).
 void setImage(Image image)
          Sets the receiver's image to the argument, which may be null.
 void setMaximized(boolean maximized)
          Sets the maximized state of the receiver.
 void setMenuBar(Menu menu)
          Sets the receiver's menu bar to the argument, which may be null.
 void setMinimized(boolean minimized)
          Sets the minimized stated of the receiver.
 void setText(java.lang.String string)
          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.
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
scroll
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, getChildren, getLayout, getTabList, layout, layout, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addKeyListener, addMouseListener, addMouseMoveListener, addPaintListener, addTraverseListener, computeSize, computeSize, forceFocus, getBackground, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getParent, getShell, getSize, getToolTipText, getVisible, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setEnabled, setFocus, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Decorations

public Decorations(Composite parent,
                   int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
style - the style of control to construct
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the parent is null
SWTException -
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
See Also:
SWT.BORDER, SWT.CLOSE, SWT.MIN, SWT.MAX, SWT.RESIZE, SWT.TITLE, SWT.NO_TRIM, SWT.SHELL_TRIM, SWT.DIALOG_TRIM, SWT.ON_TOP, Widget.checkSubclass(), Widget.getStyle()
Method Detail

getDefaultButton

public Button getDefaultButton()
Returns the receiver's default button if one had previously been set, otherwise returns null.

Returns:
the default button or null
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
setDefaultButton(org.eclipse.swt.widgets.Button)

getImage

public Image getImage()
Returns the receiver's image if it had previously been set using setImage(). The image is typically displayed by the window manager when the instance is marked as iconified, and may also be displayed somewhere in the trim when the instance is in normal or maximized states.

Note: This method will return null if called before setImage() is called. It does not provide access to a window manager provided, "default" image even if one exists.

Returns:
the image
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getMaximized

public boolean getMaximized()
Returns true if the receiver is currently maximized, and false otherwise.

Returns:
the maximized state
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
setMaximized(boolean)

getMenuBar

public Menu getMenuBar()
Returns the receiver's menu bar if one had previously been set, otherwise returns null.

Returns:
the menu bar or null
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getMinimized

public boolean getMinimized()
Returns true if the receiver is currently minimized, and false otherwise.

Returns:
the minimized state
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
setMinimized(boolean)

getText

public java.lang.String getText()
Returns the receiver's text, which is the string that the window manager will typically display as the receiver's title. If the text has not previously been set, returns an empty string.

Returns:
the text
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setDefaultButton

public void setDefaultButton(Button button)
If the argument is not null, sets the receiver's default button to the argument, and if the argument is null, sets the receiver's default button to the first button which was set as the receiver's default button (called the saved default button). If no default button had previously been set, or the saved default button was disposed, the receiver's default button will be set to null.

The default button is the button that is selected when the receiver is active and the user presses ENTER.

Parameters:
button - the new default button
Throws:
java.lang.IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the button has been disposed
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setImage

public void setImage(Image image)
Sets the receiver's image to the argument, which may be null. The image is typically displayed by the window manager when the instance is marked as iconified, and may also be displayed somewhere in the trim when the instance is in normal or maximized states.

Parameters:
image - the new image (or null)
Throws:
java.lang.IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the image has been disposed
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setMaximized

public void setMaximized(boolean maximized)
Sets the maximized state of the receiver. If the argument is true causes the receiver to switch to the maximized state, and if the argument is false and the receiver was previously maximized, causes the receiver to switch back to either the minimized or normal states.

Note: The result of intermixing calls to setMaximized(true) and setMinimized(true) will vary by platform. Typically, the behavior will match the platform user's expectations, but not always. This should be avoided if possible.

Parameters:
maximized - the new maximized state
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
setMinimized(boolean)

setMenuBar

public void setMenuBar(Menu menu)
Sets the receiver's menu bar to the argument, which may be null.

Parameters:
menu - the new menu bar
Throws:
java.lang.IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the menu has been disposed
  • ERROR_INVALID_PARENT - if the menu is not in the same widget tree
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setMinimized

public void setMinimized(boolean minimized)
Sets the minimized stated of the receiver. If the argument is true causes the receiver to switch to the minimized state, and if the argument is false and the receiver was previously minimized, causes the receiver to switch back to either the maximized or normal states.

Note: The result of intermixing calls to setMaximized(true) and setMinimized(true) will vary by platform. Typically, the behavior will match the platform user's expectations, but not always. This should be avoided if possible.

Parameters:
minimized - the new maximized state
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
setMaximized(boolean)

setText

public void setText(java.lang.String string)
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.

Parameters:
string - the new text
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the text is null
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver