How do I control the display of a JComponent's Tooltip?

前端 未结 2 1631
情书的邮戳
情书的邮戳 2020-12-21 02:44

I have a JComponent that\'s painting various shapes on itself. I\'m detecting whenever the mouse enters one of these shapes and changing the tooltip accordingly.

Th

2条回答
  •  醉酒成梦
    2020-12-21 03:05

    To solve your first issue of where the tooltip doesn't follow the mouse, if you override the getToolTipLocation(MouseEvent e) in JComponent, you can return the point for where you want to the display the tooltip. The MouseEvent will allow you to retrieve the x and y.

提交回复
热议问题