gpt4 book ai didi

java - 在 ToolTipText 上使用图标

转载 作者:行者123 更新时间:2023-12-01 18:35:41 26 4
gpt4 key购买 nike

基本上,当我将鼠标悬停在 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");

最佳答案

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

关于java - 在 ToolTipText 上使用图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22140314/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com