- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JToolTip
-
- All Implemented Interfaces:
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
public class JToolTip extends JComponent implements Accessible
用于显示组件的“提示”。 通常组件提供api来自动化使用ToolTip
的过程。 例如,任何Swing组件都可以使用JComponent
setToolTipText
方法来指定标准工具提示的文本。 希望创建自定义ToolTip
显示的组件可以覆盖JComponent
的createToolTip
方法并使用此类的子类。有关进一步的文档,请参阅Java教程中的 How to Use Tool Tips 。
警告: Swing不是线程安全的。 欲了解更多信息,请参阅Swing's Threading Policy 。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4版本开始,所有JavaBeans的长期存储支持已被添加到
java.beans
软件包中。 请参阅XMLEncoder
。- 从以下版本开始:
- 1.2
- 另请参见:
-
JComponent.setToolTipText(java.lang.String)
,JComponent.createToolTip()
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 protected class
JToolTip.AccessibleJToolTip
该类实现JToolTip
类的辅助功能支持。-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
-
Field Summary
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
构造方法摘要
构造方法 Constructor 描述 JToolTip()
创建工具提示。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 AccessibleContext
getAccessibleContext()
获取与此JToolTip关联的AccessibleContext。JComponent
getComponent()
返回工具提示应用于的组件。String
getTipText()
返回显示工具提示时显示的文本。ToolTipUI
getUI()
返回渲染此组件的L&F对象。String
getUIClassID()
返回呈现此组件的L&F类的名称。protected String
paramString()
返回此JToolTip
的字符串表示JToolTip
。void
setComponent(JComponent c)
指定工具提示描述的组件。void
setTipText(String tipText)
设置显示工具提示时显示的文本。void
updateUI()
将UI属性重置为当前外观的值。-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
-
-
-
方法详细信息
-
getUI
public ToolTipUI getUI()
返回渲染此组件的L&F对象。- 重写:
-
getUI
在JComponent
- 结果
-
呈现此组件的
ToolTipUI
对象
-
updateUI
public void updateUI()
将UI属性重置为当前外观的值。- 重写:
-
updateUI
在JComponent
- 另请参见:
-
JComponent.updateUI()
-
getUIClassID
public String getUIClassID()
返回呈现此组件的L&F类的名称。- 重写:
-
getUIClassID
在JComponent
- 结果
- 字符串“ToolTipUI”
- 另请参见:
-
JComponent.getUIClassID()
,UIDefaults.getUI(javax.swing.JComponent)
-
setTipText
@BeanProperty(preferred=true, description="Sets the text of the tooltip") public void setTipText(String tipText)
设置显示工具提示时显示的文本。 字符串tipText
可以是null
。- 参数
-
tipText
- 要显示的String
-
getTipText
public String getTipText()
返回显示工具提示时显示的文本。 返回值可能为null
。- 结果
-
显示的是
String
-
setComponent
@BeanProperty(description="Sets the component that the tooltip describes.") public void setComponent(JComponent c)
指定工具提示描述的组件。 组件c
可以是null
并且将不起作用。这是一个绑定属性。
- 参数
-
c
- 正在描述的JComponent
- 另请参见:
-
JComponent.createToolTip()
-
getComponent
public JComponent getComponent()
返回工具提示应用于的组件。 返回值可能为null
。- 结果
- 工具提示描述的组件
- 另请参见:
-
JComponent.createToolTip()
-
paramString
protected String paramString()
返回此JToolTip
的字符串表示JToolTip
。 该方法仅用于调试目的,并且返回的字符串的内容和格式可能因实现而异。 返回的字符串可能为空,但可能不是null
。- 重写:
-
paramString
在JComponent
- 结果
-
这个
JToolTip
的字符串表示JToolTip
-
getAccessibleContext
public AccessibleContext getAccessibleContext()
获取与此JToolTip关联的AccessibleContext。 对于工具提示,AccessibleContext采用AccessibleJToolTip的形式。 如有必要,将创建一个新的AccessibleJToolTip实例。- Specified by:
-
getAccessibleContext
在接口Accessible
- 重写:
-
getAccessibleContext
在Component
- 结果
- an AccessibleJToolTip that serves as the AccessibleContext of this JToolTip
-
-