Search code examples
javaswingjpaneljtooltip

JToolTip on JPanel mouseMove action


I've trying to create a JToolTip over a JPanel. The idea is, that user move over the JPanel (mouseMove) and behind the cursor will be the tooltip. But I dont know, how to set up tooltip to JPanel. I mean, that I create instance of JToolTip, setLocation by cursor (in mouseMove) and then I don't know how to set up this new tooltip to panel (like JPanel.setToolTip(newJToolTip)).


Solution

  • You can set a tooltip on a JPanel using setToolTipText(). When the mouse cursor stops, the tooltip is displayed. If you no longer need this behavior, just call the method again with null as a parameter.