Question

Basically, I need an image/icon to show up whenI hover over a swing component

//this is what i normally use to apply image to components
Icon icon = new ImageIcon(getClass().getResource("icon.png"));
label = new JLabel(icon);

what I'd like to do:

 //use an imported icon on a tool tip text and also add some texts
 label.setToolTipText(icon + "some random text");
Was it helpful?

Solution

Tool tips support HTML, so display that image as you might display it in HTML. E.G. as seen in this answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top