Class Control
- Direct Known Subclasses:
- Button,- Label,- Link,- ProgressBar,- Sash,- Scale,- Scrollable,- Slider
- Styles:
- BORDER
- LEFT_TO_RIGHT, RIGHT_TO_LEFT
- Events:
- FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, MouseDown, MouseUp, Move, Resize, Traverse, MenuDetect
IMPORTANT: This class is intended to be subclassed only within the SWT implementation.
- Since:
- 1.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddControlListener(ControlListener listener) Adds the listener to the collection of listeners who will be notified when the control is moved or resized, by sending it one of the messages defined in theControlListenerinterface.voidaddDragDetectListener(DragDetectListener listener) Adds the listener to the collection of listeners who will be notified when a drag gesture occurs, by sending it one of the messages defined in theDragDetectListenerinterface.voidaddFocusListener(FocusListener listener) Adds the listener to the collection of listeners who will be notified when the control gains or loses focus, by sending it one of the messages defined in theFocusListenerinterface.voidaddGestureListener(GestureListener listener) Adds the listener to the collection of listeners who will be notified when gesture events are generated for the control, by sending it one of the messages defined in theGestureListenerinterface.voidaddHelpListener(HelpListener listener) Adds the listener to the collection of listeners who will be notified when help events are generated for the control, by sending it one of the messages defined in theHelpListenerinterface.voidaddKeyListener(KeyListener listener) Adds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in theKeyListenerinterface.voidaddMenuDetectListener(MenuDetectListener listener) Adds the listener to the collection of listeners who will be notified when the platform-specific context menu trigger has occurred, by sending it one of the messages defined in theMenuDetectListenerinterface.voidaddMouseListener(MouseListener listener) Adds the listener to the collection of listeners who will be notified when mouse buttons are pressed and released, by sending it one of the messages defined in theMouseListenerinterface.voidaddTouchListener(TouchListener listener) Adds the listener to the collection of listeners who will be notified when touch events occur, by sending it one of the messages defined in theTouchListenerinterface.voidaddTraverseListener(TraverseListener listener) Adds the listener to the collection of listeners who will be notified when traversal events occur, by sending it one of the messages defined in theTraverseListenerinterface.computeSize(int wHint, int hHint) Returns the preferred size of the receiver.computeSize(int wHint, int hHint, boolean changed) Returns the preferred size of the receiver.booleanForces the receiver to have the keyboard focus, causing all keyboard events to be delivered to it.Returns the accessible object for the receiver.<T> TgetAdapter(Class<T> adapter) Implementation of theAdaptableinterface.Returns the receiver's background color.Returns the receiver's background image.intReturns the receiver's border width.Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null), unless the receiver is a shell.Returns the receiver's cursor, or null if it has not been set.booleanReturnstrueif the receiver is enabled, andfalseotherwise.getFont()Returns the font that the receiver will use to paint textual information.Returns the foreground color that the receiver will use to draw.Returns layout data which is associated with the receiver.Returns a point describing the receiver's location relative to its parent (or its display if its parent is null), unless the receiver is a shell.getMenu()Returns the receiver's pop up menu if it has one, or null if it does not.Returns the receiver's monitor.intReturns the orientation of the receiver, which will be one of the constantsSWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.Returns the receiver's parent, which must be aCompositeor null when the receiver is a shell that was created with null or a display for a parent.getShell()Returns the receiver's shell.getSize()Returns a point describing the receiver's size.Returns the receiver's tool tip text, or null if it has not been set.booleanReturnstrueif this control is receiving OS-level touch events, otherwisefalsebooleanReturnstrueif the receiver is visible, andfalseotherwise.booleanReturnstrueif the receiver is enabled and all ancestors up to and including the receiver's nearest ancestor shell are enabled.booleanReturnstrueif the receiver has the user-interface focus, andfalseotherwise.booleanReturnstrueif the underlying operating system supports this reparenting, otherwisefalsebooleanReturnstrueif the receiver is visible and all ancestors up to and including the receiver's nearest ancestor shell are visible.voidMoves the receiver above the specified control in the drawing order.voidMoves the receiver below the specified control in the drawing order.voidpack()Causes the receiver to be resized to its preferred size.voidpack(boolean changed) Causes the receiver to be resized to its preferred size.voidredraw()Causes the entire bounds of the receiver to be marked as needing to be redrawn.voidredraw(int x, int y, int width, int height, boolean all) Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn.voidremoveControlListener(ControlListener listener) Removes the listener from the collection of listeners who will be notified when the control is moved or resized.voidremoveDragDetectListener(DragDetectListener listener) Removes the listener from the collection of listeners who will be notified when a drag gesture occurs.voidremoveFocusListener(FocusListener listener) Removes the listener from the collection of listeners who will be notified when the control gains or loses focus.voidremoveGestureListener(GestureListener listener) Removes the listener from the collection of listeners who will be notified when gesture events are generated for the control.voidremoveHelpListener(HelpListener listener) Removes the listener from the collection of listeners who will be notified when the help events are generated for the control.voidremoveKeyListener(KeyListener listener) Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.voidremoveMenuDetectListener(MenuDetectListener listener) Removes the listener from the collection of listeners who will be notified when the platform-specific context menu trigger has occurred.voidremoveMouseListener(MouseListener listener) Removes the listener from the collection of listeners who will be notified when mouse buttons are pressed and released.voidremoveTouchListener(TouchListener listener) Removes the listener from the collection of listeners who will be notified when touch events occur.voidremoveTraverseListener(TraverseListener listener) Removes the listener from the collection of listeners who will be notified when traversal events occur.voidRequests that this control and all of its ancestors be repositioned their layouts at the earliest opportunity.voidsetBackground(Color color) Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.voidsetBackgroundImage(Image image) Sets the receiver's background image to the image specified by the argument, or to the default system color for the control if the argument is null.voidsetBounds(int x, int y, int width, int height) Sets the receiver's size and location to the rectangular area specified by the arguments.voidSets the receiver's size and location to the rectangular area specified by the argument.voidSets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.voidSets the application defined property of the receiver with the specified name to the given value.voidsetEnabled(boolean enabled) Enables the receiver if the argument istrue, and disables it otherwise.booleansetFocus()Causes the receiver to have the keyboard focus, such that all keyboard events will be delivered to it.voidSets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.voidsetForeground(Color color) Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.voidsetLayoutData(Object layoutData) Sets the layout data associated with the receiver to the argument.voidsetLocation(int x, int y) Sets the receiver's location to the point specified by the arguments which are relative to the receiver's parent (or its display if its parent is null), unless the receiver is a shell.voidsetLocation(Point location) Sets the receiver's location to the point specified by the arguments which are relative to the receiver's parent (or its display if its parent is null), unless the receiver is a shell.voidSets the receiver's pop up menu to the argument.voidsetOrientation(int orientation) Sets the orientation of the receiver, which must be one of the constantsSWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.booleanChanges the parent of the widget to be the one provided if the underlying operating system supports this feature.voidsetRedraw(boolean redraw) If the argument isfalse, causes subsequent drawing operations in the receiver to be ignored.voidsetSize(int width, int height) Sets the receiver's size to the point specified by the arguments.voidSets the receiver's size to the point specified by the argument.voidsetToolTipText(String toolTipText) Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.voidsetTouchEnabled(boolean enabled) Sets whether the receiver should accept touch events.voidsetVisible(boolean visible) Marks the receiver as visible if the argument istrue, and marks it invisible otherwise.toControl(int x, int y) Returns a point which is the result of converting the argument, which is specified in display relative coordinates, to coordinates relative to the receiver.Returns a point which is the result of converting the argument, which is specified in display relative coordinates, to coordinates relative to the receiver.toDisplay(int x, int y) Returns a point which is the result of converting the argument, which is specified in coordinates relative to the receiver, to display relative coordinates.Returns a point which is the result of converting the argument, which is specified in coordinates relative to the receiver, to display relative coordinates.voidupdate()Forces all outstanding paint requests for the widget to be processed before this method returns.Methods inherited from class org.eclipse.swt.widgets.WidgetaddDisposeListener, addListener, checkSubclass, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, toString
- 
Constructor Details- 
ControlConstructs 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 SWTwhich is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint"|" operator) two or more of thoseSWTstyle 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:
- 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:
 
 
- 
- 
Method Details- 
getParentReturns the receiver's parent, which must be aCompositeor null when the receiver is a shell that was created with null or a display for a parent.- Returns:
- the receiver's parent
- 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
 
 
- 
getShellReturns the receiver's shell. For all controls other than shells, this simply returns the control's nearest ancestor shell. Shells return themselves, even if they are children of other shells.- Returns:
- the receiver's shell
- 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:
 
- 
getMonitorReturns the receiver's monitor.- Returns:
- the receiver's monitor
- Since:
- 1.2
 
- 
setVisiblepublic void setVisible(boolean visible) Marks the receiver as visible if the argument istrue, and marks it invisible otherwise.If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, marking it visible may not actually cause it to be displayed. - Parameters:
- visible- the new visibility 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
 
 
- 
isVisiblepublic boolean isVisible()Returnstrueif the receiver is visible and all ancestors up to and including the receiver's nearest ancestor shell are visible. Otherwise,falseis returned.- Returns:
- the receiver's visibility 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:
 
- 
getVisiblepublic boolean getVisible()Returnstrueif the receiver is visible, andfalseotherwise.If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, this method may still indicate that it is considered visible even though it may not actually be showing. - Returns:
- the receiver's visibility 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
 
 
- 
setEnabledpublic void setEnabled(boolean enabled) Enables the receiver if the argument istrue, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Parameters:
- enabled- the new enabled 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
 
 
- 
getEnabledpublic boolean getEnabled()Returnstrueif the receiver is enabled, andfalseotherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Returns:
- the receiver's enabled 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:
 
- 
isEnabledpublic boolean isEnabled()Returnstrueif the receiver is enabled and all ancestors up to and including the receiver's nearest ancestor shell are enabled. Otherwise,falseis returned. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Returns:
- the receiver's enabled 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:
 
- 
setBackgroundSets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.- Parameters:
- color- the new color (or null)
- Throws:
- IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the argument 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
 
 
- 
getBackgroundReturns the receiver's background color.- Returns:
- the background color
- 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
 
 
- 
setBackgroundImageSets the receiver's background image to the image specified by the argument, or to the default system color for the control if the argument is null. The background image is tiled to fill the available space.Note: This operation is a hint and may be overridden by the platform. For example, on Windows the background of a Button cannot be changed. - Parameters:
- image- the new image (or null)
- Throws:
- IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the argument 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
 
- Since:
- 1.1
 
- 
getBackgroundImageReturns the receiver's background image.- Returns:
- the background 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
 
- Since:
- 1.1
 
- 
setForegroundSets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.- Parameters:
- color- the new color (or null)
- Throws:
- IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the argument 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
 
 
- 
getForegroundReturns the foreground color that the receiver will use to draw.- Returns:
- the receiver's foreground color
- 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
 
 
- 
setFontSets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.- Parameters:
- font- the new font (or null)
- Throws:
- IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the argument 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
 
 
- 
getFontReturns the font that the receiver will use to paint textual information.- Returns:
- the receiver's font
- 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
 
 
- 
setCursorSets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.When the mouse pointer passes over a control its appearance is changed to match the control's cursor. - Parameters:
- cursor- the new cursor (or null)
- Throws:
- IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the argument 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
 
- Since:
- 1.2
 
- 
getCursorReturns the receiver's cursor, or null if it has not been set.When the mouse pointer passes over a control its appearance is changed to match the control's cursor. - Returns:
- the receiver's cursor 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
 
- Since:
- 1.2
 
- 
setFocuspublic boolean setFocus()Causes the receiver to have the keyboard focus, such that all keyboard events will be delivered to it. Focus reassignment will respect applicable platform constraints.- Returns:
- trueif the control got focus, and- falseif it was unable to.
- 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:
 
- 
forceFocuspublic boolean forceFocus()Forces the receiver to have the keyboard focus, causing all keyboard events to be delivered to it.- Returns:
- trueif the control got focus, and- falseif it was unable to.
- 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:
 
- 
isFocusControlpublic boolean isFocusControl()Returnstrueif the receiver has the user-interface focus, andfalseotherwise.- Returns:
- the receiver's focus 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
 
 
- 
getBoundsReturns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null), unless the receiver is a shell. In this case, the location is relative to the display.- Returns:
- the receiver's bounding rectangle
- 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
 
 
- 
setBoundsSets the receiver's size and location to the rectangular area specified by the argument. Thexandyfields of the rectangle are relative to the receiver's parent (or its display if its parent is null).Note: Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead. - Parameters:
- bounds- the new bounds for the receiver
- 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
 
 
- 
setBoundspublic void setBounds(int x, int y, int width, int height) Sets the receiver's size and location to the rectangular area specified by the arguments. Thexandyarguments are relative to the receiver's parent (or its display if its parent is null), unless the receiver is a shell. In this case, thexandyarguments are relative to the display.Note: Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead. - Parameters:
- x- the new x coordinate for the receiver
- y- the new y coordinate for the receiver
- width- the new width for the receiver
- height- the new height for the receiver
- 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
 
 
- 
setLocationSets the receiver's location to the point specified by the arguments which are relative to the receiver's parent (or its display if its parent is null), unless the receiver is a shell. In this case, the point is relative to the display.- Parameters:
- location- the new location for the receiver
- 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
 
 
- 
setLocationpublic void setLocation(int x, int y) Sets the receiver's location to the point specified by the arguments which are relative to the receiver's parent (or its display if its parent is null), unless the receiver is a shell. In this case, the point is relative to the display.- Parameters:
- x- the new x coordinate for the receiver
- y- the new y coordinate for the receiver
- 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
 
 
- 
getLocationReturns a point describing the receiver's location relative to its parent (or its display if its parent is null), unless the receiver is a shell. In this case, the point is relative to the display.- Returns:
- the receiver's location
- 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
 
 
- 
setSizeSets the receiver's size to the point specified by the argument.Note: Attempting to set the width or height of the receiver to a negative number will cause them to be set to zero instead. - Parameters:
- size- the new size for the receiver
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the point 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
 
 
- 
setSizepublic void setSize(int width, int height) Sets the receiver's size to the point specified by the arguments.Note: Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead. - Parameters:
- width- the new width for the receiver
- height- the new height for the receiver
- 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
 
 
- 
getSizeReturns a point describing the receiver's size. The x coordinate of the result is the width of the receiver. The y coordinate of the result is the height of the receiver.- Returns:
- the receiver's size
- 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
 
 
- 
computeSizeReturns the preferred size of the receiver.The preferred size of a control is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask a control questions such as "Given a particular width, how high does the control need to be to show all of the contents?" To indicate that the caller does not wish to constrain a particular dimension, the constant SWT.DEFAULTis passed for the hint.- Parameters:
- wHint- the width hint (can be- SWT.DEFAULT)
- hHint- the height hint (can be- SWT.DEFAULT)
- Returns:
- the preferred size of the control
- 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:
- 
- Layout
- getBorderWidth()
- getBounds()
- getSize()
- pack(boolean)
- "computeTrim, getClientArea for controls that implement them"
 
 
- 
computeSizeReturns the preferred size of the receiver.The preferred size of a control is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask a control questions such as "Given a particular width, how high does the control need to be to show all of the contents?" To indicate that the caller does not wish to constrain a particular dimension, the constant SWT.DEFAULTis passed for the hint.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 befalse, so layout manager caches can be retained.- Parameters:
- wHint- the width hint (can be- SWT.DEFAULT)
- hHint- the height hint (can be- SWT.DEFAULT)
- changed-- trueif the control's contents have changed, and- falseotherwise
- Returns:
- the preferred size of the control.
- 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:
- 
- Layout
- getBorderWidth()
- getBounds()
- getSize()
- pack(boolean)
- "computeTrim, getClientArea for controls that implement them"
 
 
- 
packpublic void pack()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.- 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:
 
- 
packpublic void pack(boolean changed) 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 befalse, so layout manager caches can be retained.- Parameters:
- changed- whether or not the receiver's contents have changed
- 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:
 
- 
getBorderWidthpublic int getBorderWidth()Returns the receiver's border width. Note: When the theming defines different border widths for the four edges, this method returns the maximum border width.- Returns:
- the border width
- 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
 
 
- 
toControlReturns a point which is the result of converting the argument, which is specified in display relative coordinates, to coordinates relative to the receiver.- Parameters:
- x- the x coordinate to be translated
- y- the y coordinate to be translated
- Returns:
- the translated coordinates
- 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
 
 
- 
toControlReturns a point which is the result of converting the argument, which is specified in display relative coordinates, to coordinates relative to the receiver.- Parameters:
- point- the point to be translated (must not be null)
- Returns:
- the translated coordinates
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the point 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
 
 
- 
toDisplayReturns a point which is the result of converting the argument, which is specified in coordinates relative to the receiver, to display relative coordinates.- Parameters:
- x- the x coordinate to be translated
- y- the y coordinate to be translated
- Returns:
- the translated coordinates
- 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
 
 
- 
toDisplayReturns a point which is the result of converting the argument, which is specified in coordinates relative to the receiver, to display relative coordinates.- Parameters:
- point- the point to be translated (must not be null)
- Returns:
- the translated coordinates
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the point 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
 
 
- 
getLayoutDataReturns layout data which is associated with the receiver.- Returns:
- the receiver's layout data
- 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
 
 
- 
setLayoutDataSets the layout data associated with the receiver to the argument.- Parameters:
- layoutData- the new layout data for the receiver.
- 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
 
 
- 
setToolTipTextSets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.- Parameters:
- toolTipText- the new tool tip text (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
 
 
- 
getToolTipTextReturns the receiver's tool tip text, or null if it has not been set.- Returns:
- the receiver's tool tip 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
 
 
- 
setMenuSets the receiver's pop up menu to the argument. All controls may optionally have a pop up menu that is displayed when the user requests one for the control. The sequence of key strokes, button presses and/or button releases that are used to request a pop up menu is platform specific.Note: Disposing of a control that has a pop up menu will dispose of the menu. To avoid this behavior, set the menu to null before the control is disposed. - Parameters:
- menu- the new pop up menu
- Throws:
- IllegalArgumentException-- ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu
- ERROR_INVALID_PARENT - if the menu is not in the same widget tree
- ERROR_INVALID_ARGUMENT - if the menu 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
 
 
- 
getMenuReturns the receiver's pop up menu if it has one, or null if it does not. All controls may optionally have a pop up menu that is displayed when the user requests one for the control. The sequence of key strokes, button presses and/or button releases that are used to request a pop up menu is platform specific.- Returns:
- the receiver's menu
- 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
 
 
- 
moveAboveMoves the receiver above the specified control in the drawing order. If the argument is null, then the receiver is moved to the top of the drawing order. The control at the top of the drawing order will not be covered by other controls even if they occupy intersecting areas.- Parameters:
- control- the sibling control (or null)
- Throws:
- IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the control 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
 
- See Also:
 
- 
moveBelowMoves the receiver below the specified control in the drawing order. If the argument is null, then the receiver is moved to the bottom of the drawing order. The control at the bottom of the drawing order will be covered by all other controls which occupy intersecting areas.- Parameters:
- control- the sibling control (or null)
- Throws:
- IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the control 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
 
- See Also:
 
- 
getAdapterDescription copied from class:WidgetImplementation of theAdaptableinterface.IMPORTANT: This method is not part of the RWT public API. It is marked public only so that it can be shared within the packages provided by RWT. It should never be accessed from application code. - Specified by:
- getAdapterin interface- Adaptable
- Overrides:
- getAdapterin class- Widget
- Parameters:
- adapter- the lookup class
- Returns:
- an object that can be cast to the given class or nullif there is no adapter associated with the given class.
 
- 
addControlListenerAdds the listener to the collection of listeners who will be notified when the control is moved or resized, by sending it one of the messages defined in theControlListenerinterface.- Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- See Also:
 
- 
removeControlListenerRemoves the listener from the collection of listeners who will be notified when the control is moved or resized.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- See Also:
 
- 
addMouseListenerAdds the listener to the collection of listeners who will be notified when mouse buttons are pressed and released, by sending it one of the messages defined in theMouseListenerinterface.- Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.1
- See Also:
 
- 
removeMouseListenerRemoves the listener from the collection of listeners who will be notified when mouse buttons are pressed and released.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.1
- See Also:
 
- 
addKeyListenerAdds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in theKeyListenerinterface.Note: the key events in RWT are not meant for general purpose. - Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.2
- See Also:
 
- 
removeKeyListenerRemoves the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.2
- See Also:
 
- 
addTraverseListenerAdds the listener to the collection of listeners who will be notified when traversal events occur, by sending it one of the messages defined in theTraverseListenerinterface.- Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.2
- See Also:
 
- 
removeTraverseListenerRemoves the listener from the collection of listeners who will be notified when traversal events occur.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.2
- See Also:
 
- 
addFocusListenerAdds the listener to the collection of listeners who will be notified when the control gains or loses focus, by sending it one of the messages defined in theFocusListenerinterface.- Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- See Also:
 
- 
removeFocusListenerRemoves the listener from the collection of listeners who will be notified when the control gains or loses focus.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- See Also:
 
- 
addHelpListenerAdds the listener to the collection of listeners who will be notified when help events are generated for the control, by sending it one of the messages defined in theHelpListenerinterface.- Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.3
- See Also:
 
- 
removeHelpListenerRemoves the listener from the collection of listeners who will be notified when the help events are generated for the control.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.3
- See Also:
 
- 
addDragDetectListenerAdds the listener to the collection of listeners who will be notified when a drag gesture occurs, by sending it one of the messages defined in theDragDetectListenerinterface.- Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.3
- See Also:
 
- 
removeDragDetectListenerRemoves the listener from the collection of listeners who will be notified when a drag gesture occurs.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.3
- See Also:
 
- 
addMenuDetectListenerAdds the listener to the collection of listeners who will be notified when the platform-specific context menu trigger has occurred, by sending it one of the messages defined in theMenuDetectListenerinterface.- Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.3
- See Also:
 
- 
removeMenuDetectListenerRemoves the listener from the collection of listeners who will be notified when the platform-specific context menu trigger has occurred.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.3
- See Also:
 
- 
requestLayoutpublic void requestLayout()Requests that this control and all of its ancestors be repositioned their layouts at the earliest opportunity. This should be invoked after modifying the control in order to inform any dependent layouts of the change.The control will not be repositioned synchronously. This method is fast-running and only marks the control for future participation in a deferred layout. Invoking this method multiple times before the layout occurs is an inexpensive no-op. - Since:
- 3.1
 
- 
setRedrawpublic void setRedraw(boolean redraw) If the argument isfalse, causes subsequent drawing operations in the receiver to be ignored. No drawing of any kind can occur in the receiver until the flag is set to true. Graphics operations that occurred while the flag wasfalseare lost. When the flag is set totrue, the entire widget is marked as needing to be redrawn. Nested calls to this method are stacked.Note: This operation is a hint and may not be supported on some platforms or for some widgets. Note: With RAP we can't really force a redraw. This is just a fake to enable event notifications that come on OS systems with redraws. - Parameters:
- redraw- the new redraw 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
 
 
- 
redrawpublic void redraw()Causes the entire bounds of the receiver to be marked as needing to be redrawn.Note: With RAP we can't really force a redraw. This is just a fake to enable event notifications that come on OS systems with redraws. - 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
 
 
- 
redrawpublic void redraw(int x, int y, int width, int height, boolean all) Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn. The next time a paint request is processed, that area of the receiver will be painted, including the background. If theallflag istrue, any children of the receiver which intersect with the specified area will also paint their intersecting areas. If theallflag isfalse, the children will not be painted.- Parameters:
- x- the x coordinate of the area to draw
- y- the y coordinate of the area to draw
- width- the width of the area to draw
- height- the height of the area to draw
- all-- trueif children should redraw, and- falseotherwise
- 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
 
- Since:
- 1.3
- See Also:
 
- 
updatepublic void update()Forces all outstanding paint requests for the widget to be processed before this method returns. If there are no outstanding paint request, this method does nothing.Note: This method does not cause a redraw. - 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
 
- Since:
- 1.3
 
- 
setParentChanges the parent of the widget to be the one provided if the underlying operating system supports this feature. Returnstrueif the parent is successfully changed.- Parameters:
- parent- the new parent for the control.
- Returns:
- trueif the parent is changed and- falseotherwise.
- Throws:
- IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the argument has been disposed
- ERROR_NULL_ARGUMENT - if the parent 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
 
- Since:
- 1.3
 
- 
isReparentablepublic boolean isReparentable()Returnstrueif the underlying operating system supports this reparenting, otherwisefalse- Returns:
- trueif the widget can be reparented, otherwise- false
- 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
 
- Since:
- 1.3
 
- 
setOrientationpublic void setOrientation(int orientation) Sets the orientation of the receiver, which must be one of the constantsSWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.- Parameters:
- orientation- new orientation style
- 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
 
- Since:
- 1.4
 
- 
getOrientationpublic int getOrientation()Returns the orientation of the receiver, which will be one of the constantsSWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.- Returns:
- the orientation style
- 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
 
- Since:
- 1.4
 
- 
getAccessibleReturns the accessible object for the receiver.If this is the first time this object is requested, then the object is created and returned. The object returned by getAccessible() does not need to be disposed. - Returns:
- the accessible object
- 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
 
- Since:
- 1.4
- See Also:
 
- 
addGestureListenerAdds the listener to the collection of listeners who will be notified when gesture events are generated for the control, by sending it one of the messages defined in theGestureListenerinterface.- Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.4
- See Also:
 
- 
removeGestureListenerRemoves the listener from the collection of listeners who will be notified when gesture events are generated for the control.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.4
- See Also:
 
- 
addTouchListenerAdds the listener to the collection of listeners who will be notified when touch events occur, by sending it one of the messages defined in theTouchListenerinterface.NOTE: You must also call setTouchEnabledto notify the windowing toolkit that you want touch events to be generated.- Parameters:
- listener- the listener which should be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.4
- See Also:
 
- 
removeTouchListenerRemoves the listener from the collection of listeners who will be notified when touch events occur.- Parameters:
- listener- the listener which should no longer be notified
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener 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
 
- Since:
- 1.4
- See Also:
 
- 
setTouchEnabledpublic void setTouchEnabled(boolean enabled) Sets whether the receiver should accept touch events. By default, a Control does not accept touch events. No error or exception is thrown if the underlying hardware does not support touch input.- Parameters:
- enabled- the new touch-enabled 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
 
- Since:
- 1.4
 
- 
getTouchEnabledpublic boolean getTouchEnabled()Returnstrueif this control is receiving OS-level touch events, otherwisefalseNote that this method will return false if the current platform does not support touch-based input. If this method does return true, gesture events will not be sent to the control. - Returns:
- trueif the widget is currently receiving touch events;- falseotherwise.
- 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
 
- Since:
- 1.4
 
- 
setDataDescription copied from class:WidgetSets the application defined property of the receiver with the specified name to the given value.Applications may associate arbitrary objects with the receiver in this fashion. If the objects stored in the properties need to be notified when the widget is disposed of, it is the application's responsibility to hook the Dispose event on the widget and do so. 
 
-