开发者

Why getToolTipText is never called?

开发者 https://www.devze.com 2022-12-10 04:37 出处:网络
I have got a JComponent. The paintComponent method is overridden. I mentioned that tooltips were not occuring reliable. Sometimes they were displayed and sometime they didn\'t. Now I don\'t开发者_如何

I have got a JComponent. The paintComponent method is overridden. I mentioned that tooltips were not occuring reliable. Sometimes they were displayed and sometime they didn't. Now I don't开发者_如何学Go see tooltips anymore on this component. I overwrote getToolTipText(MouseEvent e) to specify the contents of the tooltips. But the methods getToolTipText() and getToolTipText(MouseEvent e) are never called!

What could be wrong here? What can I do to fix it?


I believe you will need to call ToolTipManager.registerComponent. It's an optimisation, apparently.


You'll need to register your component with the tooltip manager.

The default implementation of setToolTipText() will do this for you, but if you'd like to override getToolTipText() instead, you'll need to add this line somewhere, IE, in your component's constructor:

ToolTipManager.sharedInstance().registerComponent(this);


Have you set the tooltip with the method "setToolTipText(String)"?

When the tooltip is not set (or resettet with the value "null"), then the tooltip will not be displayed. (And i suggest the getToolTipText() method will not be called)

This link may help you with this problem: How To use Tooltips

(sorry about my english, i think it's not the best,,, ;-) )


First you need to register with the TooltipManager via

TooltipManager.registerComponent()

Even if that doesent work then

  1. Check the value of TooltipManager.getInitialDelay()
  2. Check the value of TooltipManager.isEnabled()
0

精彩评论

暂无评论...
验证码 换一张
取 消