Java 在ToolTipText上使用图标
基本上,当我将鼠标悬停在swing组件上时,我需要一个图像/图标来显示Java 在ToolTipText上使用图标,java,swing,icons,tooltip,jlabel,Java,Swing,Icons,Tooltip,Jlabel,基本上,当我将鼠标悬停在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 so
//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");
工具提示支持HTML,所以可以像在HTML中一样显示图像。如图所示
工具提示支持HTML,因此可以像在HTML中显示一样显示该图像。如图所示
在编程时不要为拼写操心。告诉stack overflow的拼写检查,在编程时不要为拼写操心。告诉stack overflow的拼写检查,我不知道编程语言HTML不是编程语言。好的,我成功了,但是我如何用我电脑文件夹中的图片链接替换internet上图片的链接呢?我尝试了我所知道的关于链接的一切,但都没有成功。“我如何用我电脑文件夹中的图片链接替换internet上图片的链接”使用您最初使用的方法
getClass().getResource(“icon.png”)
你认为返回的是什么,一匹小马?@andrewhompson我想他指的是HTML中的图像链接。工具提示,而不是他的图标。(是的,这不是他最初问题的一部分)我不知道编程语言HTML不是一种编程语言。好吧,我让它工作了,但是我如何用我电脑文件夹中图片的链接替换互联网上图片的链接,我尝试了我所知道的关于链接的一切,但它就是做不到“如何用我电脑文件夹中的图片链接替换internet上的图片链接”使用您最初使用的。getClass().getResource(“icon.png”)
您认为会返回什么,一匹小马?@andrewhompson我想他指的是HTML中的图片链接。工具提示,而不是他的图标。(是的,这不是他最初问题的一部分)