java.lang.Object
java.awt.event.MouseAdapter
javax.swing.ToolTipManager
- 所有已实现的接口:
-
MouseListener,MouseMotionListener,MouseWheelListener,EventListener
管理系统中所有的
工具提示。
ToolTipManager包含许多属性,用于配置工具提示何时变得可见,以及何时隐藏。考虑一个组件,根据鼠标所在位置有不同的工具提示,比如JTree。当鼠标移动到JTree并悬停在具有有效工具提示的区域时,工具提示将在initialDelay毫秒后变为可见。在dismissDelay毫秒后,工具提示将被隐藏。如果鼠标悬停在具有有效工具提示的区域,并且工具提示当前可见,当鼠标移动到没有有效工具提示的区域时,工具提示将被隐藏。如果鼠标在reshowDelay毫秒内再次移动到具有有效工具提示的区域,则工具提示将立即显示,否则将在initialDelay毫秒后再次显示。
- 自从:
- 1.2
- 参见:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class定时器内部操作。protected class定时器外部操作。protected class仍在定时器内部操作。 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean启用重量级弹出窗口。protected boolean启用轻量级弹出窗口。 -
Method Summary
Modifier and TypeMethodDescriptionint返回消失延迟值。int返回初始延迟值。int返回重新显示延迟属性。boolean如果此对象已启用,则返回true。boolean返回true如果使用轻量级(全Java)工具提示,或者返回false如果使用重量级(本机对等体)工具提示。voidmouseDragged(MouseEvent event) 当鼠标按下并拖动时调用。voidmouseEntered(MouseEvent event) 当鼠标进入组件的区域时调用。voidmouseExited(MouseEvent event) 当鼠标退出组件的区域时调用。voidmouseMoved(MouseEvent event) 当鼠标移动时调用。voidmousePressed(MouseEvent event) 当鼠标按下时调用。voidregisterComponent(JComponent component) 注册组件以进行工具提示管理。voidsetDismissDelay(int milliseconds) 指定消失延迟值。voidsetEnabled(boolean flag) 启用或禁用工具提示。voidsetInitialDelay(int milliseconds) 指定初始延迟值。voidsetLightWeightPopupEnabled(boolean aFlag) 在显示JToolTip时,如果适合,ToolTipManager会选择使用轻量级JPanel。voidsetReshowDelay(int milliseconds) 用于指定用户必须等待initialDelay毫秒之后才会显示工具提示的时间量。static ToolTipManager返回一个共享的ToolTipManager实例。voidunregisterComponent(JComponent component) 从工具提示控制中移除组件。Methods declared in class java.awt.event.MouseAdapter
mouseClicked, mouseReleased, mouseWheelMoved
-
Field Details
-
lightWeightPopupEnabled
protected boolean lightWeightPopupEnabled启用轻量级弹出窗口。 -
heavyWeightPopupEnabled
protected boolean heavyWeightPopupEnabled启用重量级弹出窗口。
-
-
Method Details
-
setEnabled
public void setEnabled(boolean flag) 启用或禁用工具提示。- 参数:
-
flag- true表示启用提示,否则为false
-
isEnabled
public boolean isEnabled()如果此对象已启用,则返回true。- 返回:
- 如果此对象已启用,则返回true,否则返回false
-
setLightWeightPopupEnabled
public void setLightWeightPopupEnabled(boolean aFlag) 在显示JToolTip时,如果适合,ToolTipManager会选择使用轻量级JPanel。 这个方法允许您禁用此功能。如果您的应用程序混合使用轻量级和重量级组件,则必须禁用它。- 参数:
-
aFlag- 如果需要轻量级面板,则为true,否则为false
-
isLightWeightPopupEnabled
public boolean isLightWeightPopupEnabled()返回true如果使用轻量级(全Java)工具提示,或者返回false如果使用重量级(本机对等体)工具提示。- 返回:
-
如果使用轻量级
工具提示,则返回true
-
setInitialDelay
public void setInitialDelay(int milliseconds) 指定初始延迟值。- 参数:
-
milliseconds- 在光标暂停后显示工具提示之前延迟的毫秒数 - 参见:
-
getInitialDelay
public int getInitialDelay()返回初始延迟值。- 返回:
- 一个表示初始延迟值的整数,以毫秒为单位
- 参见:
-
setDismissDelay
public void setDismissDelay(int milliseconds) 指定消失延迟值。- 参数:
-
milliseconds- 在取走工具提示之前延迟的毫秒数 - 参见:
-
getDismissDelay
public int getDismissDelay()返回消失延迟值。- 返回:
- 一个表示消失延迟值的整数,以毫秒为单位
- 参见:
-
setReshowDelay
public void setReshowDelay(int milliseconds) 用于指定用户必须等待initialDelay毫秒之后才会显示工具提示的时间量。也就是说,如果工具提示被隐藏,并且用户在milliseconds毫秒内移动到具有有效工具提示的同一组件的区域,则工具提示将立即显示。否则,如果用户在milliseconds毫秒后移动到具有有效工具提示的区域,则用户必须再等待额外的initialDelay毫秒才能再次显示工具提示。- 参数:
-
milliseconds- 毫秒数 - 参见:
-
getReshowDelay
public int getReshowDelay()返回重新显示延迟属性。- 返回:
- 重新显示延迟属性
- 参见:
-
registerComponent
注册组件以进行工具提示管理。只有在
component具有焦点绑定时,此方法才会注册显示和隐藏工具提示文本的键绑定。这样做是为了避免调用此方法导致通常不可聚焦的组件(如JLabel)变为可聚焦。- 参数:
-
component- 要添加的JComponent对象 - 参见:
-
unregisterComponent
从工具提示控制中移除组件。- 参数:
-
component- 要移除的JComponent对象
-
mouseEntered
当鼠标进入组件的区域时调用。这确定是否应显示工具提示。- 指定者:
-
mouseEntered在接口MouseListener中 - 参数:
-
event- 相关事件
-
mouseExited
当鼠标退出组件的区域时调用。任何正在显示的工具提示应该被隐藏。- 指定者:
-
mouseExited在接口MouseListener中 - 参数:
-
event- 相关事件
-
mousePressed
当鼠标按下时调用。任何正在显示的工具提示应该被隐藏。- 指定者:
-
mousePressed在接口MouseListener中 - 参数:
-
event- 相关事件
-
mouseDragged
当鼠标按下并拖动时调用。不执行任何操作。- 指定者:
-
mouseDragged在接口MouseMotionListener中 - 覆盖:
-
mouseDragged在类MouseAdapter中 - 参数:
-
event- 相关事件
-
mouseMoved
当鼠标移动时调用。确定是否应显示工具提示。- 指定者:
-
mouseMoved在接口MouseMotionListener中 - 覆盖:
-
mouseMoved在类MouseAdapter中 - 参数:
-
event- 相关事件
-