public class ToolTipSupport extends Object
ToolTipSupport.INITIAL_DELAY
milliseconds the enterTimer fires
and the ToolTipSupport.updateToolTip()
method is called which searches
for the action named ExtKit.buildToolTipAction
and if found
it executes it. The tooltips can be displayed by either calling
ToolTipSupport.setToolTipText(java.lang.String)
or ToolTipSupport.setToolTip(javax.swing.JComponent)
.Modifier and Type | Field and Description |
---|---|
static int |
DISMISS_DELAY
Delay after which the tooltip will be hidden automatically
in milliseconds.
|
static int |
FLAG_HIDE_ON_MOUSE_MOVE |
static int |
FLAG_HIDE_ON_TIMER |
static int |
FLAG_PERMANENT |
static int |
FLAGS_HEAVYWEIGHT_TOOLTIP |
static int |
FLAGS_LIGHTWEIGHT_TOOLTIP |
static int |
INITIAL_DELAY
Initial delay before the tooltip is shown in milliseconds.
|
static String |
PROP_DISMISS_DELAY
Property for the dismiss delay change
|
static String |
PROP_ENABLED
Property for the enabled flag change
|
static String |
PROP_INITIAL_DELAY
Property for the initial delay change
|
static String |
PROP_STATUS
Property for the visibility status change.
|
static String |
PROP_TOOL_TIP
Property for the tooltip component change
|
static String |
PROP_TOOL_TIP_TEXT
Property for the tooltip text change
|
static int |
STATUS_COMPONENT_VISIBLE
Status indicating that the tooltip is visible
because
ToolTipSupport.setToolTip(javax.swing.JComponent)
was called. |
static int |
STATUS_HIDDEN
Status indicating that the tooltip is not showing on the screen.
|
static int |
STATUS_TEXT_VISIBLE
Status indicating that the tooltip is visible
because
ToolTipSupport.setToolTipText(java.lang.String)
was called. |
static int |
STATUS_VISIBILITY_ENABLED
Status indicating that the tooltip is not showing on the screen
but once either the
ToolTipSupport.setToolTipText(java.lang.String)
or ToolTipSupport.setToolTip(javax.swing.JComponent) gets called
the tooltip will become visible. |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add the listener for the property changes.
|
protected void |
componentToolTipTextChanged(PropertyChangeEvent evt)
Called automatically when the
JComponent.TOOL_TIP_TEXT_KEY
property of the corresponding editor component
gets changed.By default it calls ToolTipSupport.setToolTipText(java.lang.String)
with the new tooltip text of the component. |
protected JComponent |
createDefaultToolTip()
Create the default tooltip component.
|
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Fire the change of the given property.
|
int |
getDismissDelay() |
String |
getIdentifierUnderCursor()
Helper method to get the identifier
under the mouse cursor.
|
int |
getInitialDelay() |
MouseEvent |
getLastMouseEvent() |
int |
getStatus() |
JComponent |
getToolTip() |
String |
getToolTipText() |
boolean |
isEnabled() |
boolean |
isToolTipVisible() |
void |
removePropertyChangeListener(PropertyChangeListener listener) |
void |
setDismissDelay(int delay)
Set the delay between displaying
of the tooltip and its automatic hiding
in milliseconds.
|
void |
setEnabled(boolean enabled)
Set whether the tooltip support is enabled.
|
void |
setInitialDelay(int delay)
Set the delay between stopping
mouse movement and displaying
of the tooltip in milliseconds.
|
void |
setToolTip(JComponent toolTip)
Set the tooltip component.
|
void |
setToolTip(JComponent toolTip,
PopupManager.HorizontalBounds horizontalBounds,
Point placeAt,
int horizontalAdjustment,
int verticalAdjustment,
int flags)
Sets the tooltip.
|
void |
setToolTip(JComponent toolTip,
PopupManager.HorizontalBounds horizontalBounds,
PopupManager.Placement placement) |
void |
setToolTip(JComponent toolTip,
PopupManager.HorizontalBounds horizontalBounds,
PopupManager.Placement placement,
int horizontalAdjustment,
int verticalAdjustment) |
void |
setToolTip(JComponent toolTip,
PopupManager.HorizontalBounds horizontalBounds,
PopupManager.Placement placement,
int horizontalAdjustment,
int verticalAdjustment,
int flags) |
void |
setToolTipText(String text)
Set the tooltip text to make the tooltip
to be shown on the screen.
|
void |
setToolTipVisible(boolean visible)
Set the visibility of the tooltip.
|
void |
setToolTipVisible(boolean visible,
boolean updateFromView)
Set the visibility of the tooltip.
|
protected void |
updateToolTip()
Update the tooltip by running corresponding action
ExtKit.buildToolTipAction . |
public static final String PROP_TOOL_TIP
public static final String PROP_TOOL_TIP_TEXT
public static final String PROP_STATUS
public static final String PROP_ENABLED
public static final String PROP_INITIAL_DELAY
public static final String PROP_DISMISS_DELAY
public static final int INITIAL_DELAY
public static final int DISMISS_DELAY
public static final int STATUS_HIDDEN
public static final int STATUS_VISIBILITY_ENABLED
ToolTipSupport.setToolTipText(java.lang.String)
or ToolTipSupport.setToolTip(javax.swing.JComponent)
gets called
the tooltip will become visible.public static final int STATUS_TEXT_VISIBLE
ToolTipSupport.setToolTipText(java.lang.String)
was called.public static final int STATUS_COMPONENT_VISIBLE
ToolTipSupport.setToolTip(javax.swing.JComponent)
was called.public static final int FLAG_HIDE_ON_MOUSE_MOVE
public static final int FLAG_HIDE_ON_TIMER
public static final int FLAG_PERMANENT
public static final int FLAGS_LIGHTWEIGHT_TOOLTIP
public static final int FLAGS_HEAVYWEIGHT_TOOLTIP
public final JComponent getToolTip()
public void setToolTip(JComponent toolTip)
toolTip
- component that either contains the tooltip
or that will display a text tooltip.public void setToolTip(JComponent toolTip, PopupManager.HorizontalBounds horizontalBounds, PopupManager.Placement placement)
public void setToolTip(JComponent toolTip, PopupManager.HorizontalBounds horizontalBounds, PopupManager.Placement placement, int horizontalAdjustment, int verticalAdjustment)
public void setToolTip(JComponent toolTip, PopupManager.HorizontalBounds horizontalBounds, Point placeAt, int horizontalAdjustment, int verticalAdjustment, int flags)
PopupManager.ScrollBarBounds
or the viewport PopupManager.ViewPortBounds
. Position
of caret in the editor is completely ignored.toolTip
- the tooltip componenthorizontalBounds
- positioning relative to the viewport or scrollbar (scroller)placeAt
- x,y coordinates to place the tooltiphorizontalAdjustment
- horizontal inset between tooltip component and the tooltip floaterverticalAdjustment
- vertical inset between tooltip component and the tooltip floaterflags
- various flags, see FLAG_* constants in this class.public void setToolTip(JComponent toolTip, PopupManager.HorizontalBounds horizontalBounds, PopupManager.Placement placement, int horizontalAdjustment, int verticalAdjustment, int flags)
protected JComponent createDefaultToolTip()
protected void updateToolTip()
ExtKit.buildToolTipAction
. This method gets
called once the enterTimer fires and it can be overriden
by children.public void setToolTipVisible(boolean visible)
visible
- whether tooltip should become visible or not.
If true the status is changed to ToolTipSupport.STATUS_VISIBILITY_ENABLED
and ToolTipSupport.updateToolTip()
is called.
It is still possible that the tooltip will not be showing on the screen in case the tooltip or tooltip text are left unchanged.
public final void setToolTipVisible(boolean visible, boolean updateFromView)
ToolTipSupport.setToolTipVisible(boolean)
, except that it can skip
forwarding the tooltip request to the view hierarchy. This is useful when
tooltips are actively displayed by the code, not initiated by user's mouse hover
or gesture. This call should be then followed by a call to setTooltip
to actually set the tooltip's value and position.
Use ToolTipSupport.setToolTipVisible(boolean)
to display a tooltip relevant to the
mouse position.
visible
- whether tooltip should become visible or not.updateFromView
- if true, ask DocumentView to build a tooltip.public boolean isToolTipVisible()
ToolTipSupport.getStatus()
gives the exact visibility state.public final int getStatus()
ToolTipSupport.STATUS_HIDDEN
or ToolTipSupport.STATUS_VISIBILITY_ENABLED
or ToolTipSupport.STATUS_TEXT_VISIBLE
or ToolTipSupport.STATUS_COMPONENT_VISIBLE
.public String getToolTipText()
public void setToolTipText(String text)
text
- tooltip text to be displayed.public String getIdentifierUnderCursor()
public boolean isEnabled()
public void setEnabled(boolean enabled)
enabled
- whether the tooltip will be enabled or not.public int getInitialDelay()
public void setInitialDelay(int delay)
public int getDismissDelay()
public void setDismissDelay(int delay)
public final MouseEvent getLastMouseEvent()
protected void componentToolTipTextChanged(PropertyChangeEvent evt)
JComponent.TOOL_TIP_TEXT_KEY
property of the corresponding editor component
gets changed.ToolTipSupport.setToolTipText(java.lang.String)
with the new tooltip text of the component.public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- listener to be added.public void removePropertyChangeListener(PropertyChangeListener listener)