在ToolTipText上使用图标

时间:2014-03-03 06:43:34

标签: java swing icons tooltip jlabel

基本上,当我将鼠标悬停在挥杆组件上时,我需要显示图像/图标

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

我想做什么:

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

1 个答案:

答案 0 :(得分:4)

工具提示支持HTML,因此您可以在HTML中显示该图像。例如。如this answer中所示。