org.eclipse.swt.widgets
Class Composite

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Control
              |
              +--org.eclipse.swt.widgets.Scrollable
                    |
                    +--org.eclipse.swt.widgets.Composite
All Implemented Interfaces:
Drawable, Runnable
Direct Known Subclasses:
Canvas

public class Composite
extends Scrollable

Instances of this class are controls being capable of containing other controls.

Styles:
NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP
Events:
(none)

Note: The NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, and NO_REDRAW_RESIZE styles are intended for use with Canvas. They can be used with Composite if you are drawing your own, but their behavior is undefined if they are used with subclasses of Composite other than Canvas.

This class may be subclassed by custom control implementors who are building controls that are constructed from aggregates of other controls.

See Also:
Canvas

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Widget
h, INCMD_DISPOSE, INCMD_EXTKEY, INCMD_KEY, INCMD_LDOWN, INCMD_LUP, INCMD_MENU, INCMD_POS, UPDATEITEM_ENABLED, UPDATEITEM_NAME, w, x, y
 
Constructor Summary
protected Composite()
          Prevents uninitialized instances from being created outside the package.
  Composite(Composite composite, int style)
          Constructs a new instance of this class.
 
Method Summary
 Control[] getChildren()
          Returns an array containing the receiver's children.
 void pack(boolean changed)
          Causes the receiver to be resized to its preferred size.
 void setLayout(Layout layout)
          Sets the layout which is associated with the receiver to be the argument which may be null.
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
getClientArea
 
Methods inherited from class org.eclipse.swt.widgets.Control
computeSize, computeSize, getLayoutData, isFocusControl, pack, setBackground, setBounds, setFocus, setLayoutData, setSize, setSize, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addListener, dispose, focusState, getBorderWidth, getDisplayArea, getSelection, getStyle, getText, isDisposed, removeListener, setBounds, setCursor, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, toString
 
Methods inherited from interface org.eclipse.swt.graphics.Drawable
drawLine, drawRect, drawText, setColor
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

Composite

protected Composite()
Prevents uninitialized instances from being created outside the package.


Composite

public Composite(Composite composite,
                 int style)
Constructs a new instance of this class. Input is the parent parent object, and a style value describing the behavior and appearance of the new instance.

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:
composite - a widget being the parent of the new instance (cannot be null)
Throws:
IllegalArgumentException -
SWTException -
See Also:
SWT#NO_BACKGROUND, SWT#NO_FOCUS, SWT#NO_MERGE_PAINTS, SWT#NO_REDRAW_RESIZE, SWT.NO_RADIO_GROUP, Widget.getStyle()
Method Detail

getChildren

public Control[] getChildren()
Returns an array containing the receiver's children.

Note: This is not the actual structure used by the receiver to maintain its list of children, so modifying the array will not affect the receiver.

Returns:
an array of children
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

setLayout

public void setLayout(Layout layout)
Sets the layout which is associated with the receiver to be the argument which may be null.

Parameters:
layout - the receiver's new layout 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

pack

public void pack(boolean changed)
Description copied from class: Control
Causes the receiver to be resized to its preferred size. For a composite, this involves computing the preferred size from its layout, if there is one.

If the changed flag is true, it indicates that the receiver's contents have changed, therefore any caches that a layout manager containing the control may have been keeping need to be flushed. When the control is resized, the changed flag will be false, so layout manager caches can be retained.

Overrides:
pack in class Control
See Also:
Control.computeSize(int, int)