java在ToolTipText上使用图标
基本上,当我将鼠标悬停在swing组件上时,我需要一个图像/图标来显示
//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 楼答案
工具提示支持HTML,所以可以像在HTML中一样显示图像。如this answer所示