Shadowkillsa
Shadowkillsa

Reputation: 77

use of icons on ToolTipText

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");

Upvotes: 1

Views: 1861

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168825

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

Upvotes: 4

Related Questions