Class ToolTip
- java.lang.Object
-
- org.eclipse.swt.widgets.Widget
-
- org.eclipse.swt.widgets.ToolTip
-
- All Implemented Interfaces:
Adaptable
public class ToolTip extends Widget
Instances of this class represent popup windows that are used to inform or warn the user.- Styles:
- BALLOON, ICON_ERROR, ICON_INFORMATION, ICON_WARNING
- Events:
- Selection
Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, and ICON_WARNING may be specified.
IMPORTANT: This class is not intended to be subclassed.
- Since:
- 1.4
- See Also:
- Tool Tips snippets, SWT Example: ControlExample, Sample code and further information
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSelectionListener(SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver is selected by the user, by sending it one of the messages defined in theSelectionListener
interface.<T> T
getAdapter(java.lang.Class<T> adapter)
Implementation of theAdaptable
interface.boolean
getAutoHide()
Returnstrue
if the receiver is automatically hidden by the platform, andfalse
otherwise.java.lang.String
getMessage()
Returns the receiver's message, which will be an empty string if it has never been set.Shell
getParent()
Returns the receiver's parent, which must be aShell
.java.lang.String
getText()
Returns the receiver's text, which will be an empty string if it has never been set.boolean
getVisible()
Returnstrue
if the receiver is visible, andfalse
otherwise.boolean
isVisible()
Returnstrue
if the receiver is visible, andfalse
otherwise.void
removeSelectionListener(SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver is selected by the user.void
setAutoHide(boolean autoHide)
Makes the receiver hide automatically whentrue
, and remain visible whenfalse
.void
setData(java.lang.String key, java.lang.Object value)
Sets the application defined property of the receiver with the specified name to the given value.void
setLocation(int x, int y)
Sets the location of the receiver, which must be a tooltip, to the point specified by the arguments which are relative to the display.void
setLocation(Point location)
Sets the location of the receiver, which must be a tooltip, to the point specified by the argument which is relative to the display.void
setMessage(java.lang.String message)
Sets the receiver's message.void
setText(java.lang.String text)
Sets the receiver's text.void
setVisible(boolean visible)
Marks the receiver as visible if the argument istrue
, and marks it invisible otherwise.-
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkSubclass, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, toString
-
-
-
-
Constructor Detail
-
ToolTip
public ToolTip(Shell 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 theint
"|" operator) two or more of thoseSWT
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.BALLOON
,SWT.ICON_ERROR
,SWT.ICON_INFORMATION
,SWT.ICON_WARNING
,Widget.checkSubclass()
,Widget.getStyle()
-
-
Method Detail
-
getAdapter
public <T> T getAdapter(java.lang.Class<T> adapter)
Description copied from class:Widget
Implementation of theAdaptable
interface.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:
getAdapter
in interfaceAdaptable
- Overrides:
getAdapter
in classWidget
- Parameters:
adapter
- the lookup class- Returns:
- an object that can be cast to the given class or
null
if there is no adapter associated with the given class.
-
getParent
public Shell getParent()
Returns the receiver's parent, which must be aShell
.- 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
-
getAutoHide
public boolean getAutoHide()
Returnstrue
if the receiver is automatically hidden by the platform, andfalse
otherwise.- Returns:
- the receiver's auto hide 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
-
setAutoHide
public void setAutoHide(boolean autoHide)
Makes the receiver hide automatically whentrue
, and remain visible whenfalse
.- Parameters:
autoHide
- the auto hide 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:
getVisible()
,setVisible(boolean)
-
isVisible
public boolean isVisible()
Returnstrue
if the receiver is visible, andfalse
otherwise.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
-
getVisible
public boolean getVisible()
Returnstrue
if the receiver is visible, andfalse
otherwise.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
-
setVisible
public 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
-
getText
public java.lang.String getText()
Returns the receiver's text, which will be an empty string if it has never been set.- Returns:
- the receiver's 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
-
setText
public void setText(java.lang.String text)
Sets the receiver's text.- Parameters:
text
- 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
-
getMessage
public java.lang.String getMessage()
Returns the receiver's message, which will be an empty string if it has never been set.- Returns:
- the receiver's message
- 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
-
setMessage
public void setMessage(java.lang.String message)
Sets the receiver's message.- Parameters:
message
- the new message- 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
-
setLocation
public void setLocation(int x, int y)
Sets the location of the receiver, which must be a tooltip, to the point specified by the arguments which are relative to the display.Note that this is different from most widgets where the location of the widget is relative to the parent.
- Parameters:
x
- the new x coordinate for the receivery
- 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
-
setLocation
public void setLocation(Point location)
Sets the location of the receiver, which must be a tooltip, to the point specified by the argument which is relative to the display.Note that this is different from most widgets where the location of the widget is relative to the parent.
Note that the platform window manager ultimately has control over the location of tooltips.
- Parameters:
location
- the new location for the receiver- Throws:
java.lang.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
-
addSelectionListener
public void addSelectionListener(SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver is selected by the user, by sending it one of the messages defined in theSelectionListener
interface.widgetSelected
is called when the receiver is selected.widgetDefaultSelected
is not called.- Parameters:
listener
- the listener which should be notified when the receiver is selected by the user- Throws:
java.lang.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:
SelectionListener
,removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,SelectionEvent
-
removeSelectionListener
public void removeSelectionListener(SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver is selected by the user.- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.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:
SelectionListener
,addSelectionListener(org.eclipse.swt.events.SelectionListener)
-
setData
public void setData(java.lang.String key, java.lang.Object value)
Description copied from class:Widget
Sets 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.
- Overrides:
setData
in classWidget
- Parameters:
key
- the name of the propertyvalue
- the new value for the property- See Also:
Widget.getData(String)
-
-