APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

public Class JToolTip

extends JComponent
implements Accessible
Class Inheritance
All Implemented Interfaces
javax.accessibility.Accessible
Annotations
@SuppressWarnings:serial
Imports
java.beans.BeanProperty, java.io.IOException, .ObjectOutputStream, .Serial, java.util.Objects, javax.accessibility.Accessible, .AccessibleContext, .AccessibleRole, javax.swing.plaf.ToolTipUI

Used to display a "Tip" for a Component. Typically components provide api to automate the process of using ToolTips. For example, any Swing component can use the JComponent setToolTipText method to specify the text for a standard tooltip. A component that wants to create a custom ToolTip display can override JComponent's createToolTip method and use a subclass of this class.

See How to Use Tool Tips in The Java Tutorial for further documentation.

Warning

Swing is not thread safe. For more information see Swing's Threading Policy.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Authors
Dave Moore, Rich Shiavi
Since
1.2
See Also
JComponent#setToolTipText, JComponent#createToolTip

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JToolTip.AccessibleJToolTip

This class implements accessibility support for the JToolTip class.

Field Summary

Modifier and TypeField and Description
pack-priv JComponent
pack-priv String
private static final String
Inherited from javax.swing.JComponent:
DEBUG_GRAPHICS_LOADEDfocusControllerivSourceComponentlistenerListpaintingChildTOOL_TIP_TEXT_KEYuiUNDEFINED_CONDITIONWHEN_ANCESTOR_OF_FOCUSED_COMPONENTWHEN_FOCUSEDWHEN_IN_FOCUSED_WINDOW

Constructor Summary

AccessConstructor and Description
public
JToolTip()

Creates a tool tip.

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
alwaysOnTop()

Overrides javax.swing.JComponent.alwaysOnTop.

Always returns true since tooltips, by definition, should always be on top of all other windows.

public AccessibleContext

Returns:

an AccessibleJToolTip that serves as the AccessibleContext of this JToolTip
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JToolTip.

public JComponent

Returns:

the component that the tooltip describes
getComponent
()

Returns the component the tooltip applies to.

public String

Returns:

the String that is displayed
getTipText
()

Returns the text that is shown when the tool tip is displayed.

public ToolTipUI

Returns:

the ToolTipUI object that renders this component
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the L&F object that renders this component.

public String

Returns:

the string "ToolTipUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the L&F class that renders this component.

protected String

Returns:

a string representation of this JToolTip
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JToolTip.

public void
setComponent(JComponent
the JComponent being described
c
)

Specifies the component that the tooltip describes.

public void
setTipText(String
the String to display
tipText
)

Sets the text to show when the tool tip is displayed.

public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property to a value from the current look and feel.

private void
writeObject(ObjectOutputStream s)

Hides javax.swing.JComponent.writeObject.

See readObject and writeObject in JComponent for more information about serialization in Swing.

Inherited from javax.swing.JComponent:
_paintImmediatelyaddAncestorListeneraddNotifyaddVetoableChangeListenercheckIfChildObscuredBySiblingclientPropertyChangedcomponentInputMapChangedcomputeVisibleRectcomputeVisibleRectcompWriteObjectNotifycontainscreateToolTipdisabledndDonedropLocationForPointenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetCreatedDoubleBuffergetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetGraphicsInvokedgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetManagingFocusBackwardTraversalKeysgetManagingFocusForwardTraversalKeysgetMaximumSizegetMinimumSizegetNextFocusableComponentgetPopupLocationgetPreferredSizegetRegisteredKeyStrokesgetRootPanegetSizegetToolTipLocationgetToolTipTextgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetWriteObjCountergetXgetYgrabFocushideisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisOptimizedDrawingEnabledisPaintingisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledisValidateRootpaintpaintBorderpaintChildrenpaintComponentpaintForceDoubleBufferedpaintImmediatelypaintImmediatelypaintToOffscreenprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingprocessKeyBindingsprocessKeyBindingsForAllComponentsprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyrectangleIsObscuredregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveNotifyremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsreshaperevalidatesafelyGetGraphicssafelyGetGraphicsscrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetCreatedDoubleBuffersetDebugGraphicsOptionssetDefaultLocalesetDoubleBufferedsetDropLocationsetEnabledsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetMaximumSizesetMinimumSizesetNextFocusableComponentsetOpaquesetPaintingChildsetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetUIPropertysetVerifyInputWhenFocusTargetsetVisiblesetWriteObjCountershouldDebugGraphicssuperProcessMouseMotionEventunregisterKeyboardActionupdate

Field Detail

componentback to summary
pack-priv JComponent component

Hides java.awt.Container.component.

tipTextback to summary
pack-priv String tipText
uiClassIDback to summary
private static final String uiClassID

Hides javax.swing.JComponent.uiClassID.

See Also
getUIClassID, readObject

Constructor Detail

JToolTipback to summary
public JToolTip()

Creates a tool tip.

Method Detail

alwaysOnTopback to summary
pack-priv boolean alwaysOnTop()

Overrides javax.swing.JComponent.alwaysOnTop.

Always returns true since tooltips, by definition, should always be on top of all other windows.

getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JToolTip. For tool tips, the AccessibleContext takes the form of an AccessibleJToolTip. A new AccessibleJToolTip instance is created if necessary.

Returns:AccessibleContext

an AccessibleJToolTip that serves as the AccessibleContext of this JToolTip

getComponentback to summary
public JComponent getComponent()

Returns the component the tooltip applies to. The returned value may be null.

Returns:JComponent

the component that the tooltip describes

See Also
JComponent#createToolTip
getTipTextback to summary
public String getTipText()

Returns the text that is shown when the tool tip is displayed. The returned value may be null.

Returns:String

the String that is displayed

getUIback to summary
public ToolTipUI getUI()

Overrides javax.swing.JComponent.getUI.

Returns the L&F object that renders this component.

Returns:ToolTipUI

the ToolTipUI object that renders this component

getUIClassIDback to summary
public String getUIClassID()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the L&F class that renders this component.

Returns:String

the string "ToolTipUI"

See Also
JComponent#getUIClassID, UIDefaults#getUI
paramStringback to summary
protected String paramString()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JToolTip. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Returns:String

a string representation of this JToolTip

setComponentback to summary
public void setComponent(JComponent c)

Specifies the component that the tooltip describes. The component c may be null and will have no effect.

This is a bound property.

Parameters
c:JComponent

the JComponent being described

Annotations
@BeanProperty
description:Sets the component that the tooltip describes.
See Also
JComponent#createToolTip
setTipTextback to summary
public void setTipText(String tipText)

Sets the text to show when the tool tip is displayed. The string tipText may be null.

Parameters
tipText:String

the String to display

Annotations
@BeanProperty
preferred:true
description:Sets the text of the tooltip
updateUIback to summary
public void updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property to a value from the current look and feel.

See Also
JComponent#updateUI
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Hides javax.swing.JComponent.writeObject.

See readObject and writeObject in JComponent for more information about serialization in Swing.

Annotations
@Serial
Exceptions
IOException:

Doc from java.awt.Container.writeObject.

if an I/O error occurs

javax.swing back to summary

protected Class JToolTip.AccessibleJToolTip

extends AccessibleJComponent
Class Inheritance
Annotations
@SuppressWarnings:serial

This class implements accessibility support for the JToolTip class. It provides an implementation of the Java Accessibility API appropriate to tool tip user-interface elements.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Field Summary

Inherited from javax.swing.JComponent.AccessibleJComponent:
accessibleFocusHandler

Constructor Summary

AccessConstructor and Description
protected
AccessibleJToolTip()

Constructs an AccessibleJToolTip.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

a localized String describing this object.
getAccessibleDescription
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleDescription.

Get the accessible description of this object.

public AccessibleRole

Returns:

an instance of AccessibleRole describing the role of the object
getAccessibleRole
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

Inherited from javax.swing.JComponent.AccessibleJComponent:
addPropertyChangeListenergetAccessibleChildgetAccessibleChildrenCountgetAccessibleExtendedComponentgetAccessibleKeyBindinggetAccessibleNamegetAccessibleStateSetgetBorderTitlegetTitledBorderTextgetToolTipTextremovePropertyChangeListener

Constructor Detail

AccessibleJToolTipback to summary
protected AccessibleJToolTip()

Constructs an AccessibleJToolTip.

Method Detail

getAccessibleDescriptionback to summary
public String getAccessibleDescription()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleDescription.

Get the accessible description of this object.

Returns:String

a localized String describing this object.

getAccessibleRoleback to summary
public AccessibleRole getAccessibleRole()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

Returns:AccessibleRole

an instance of AccessibleRole describing the role of the object