Java:如何使用AWT显示多行工具提示?
我编写了一个应用程序,现在正在制作一个托盘图标。现在我想为托盘图标设置多行工具提示文本。但我不知道怎么办。我知道如何使用 Swing 执行此操作:
component.setToolTipText("<html>Line 1<br>Line2</html>");
但这不适用于 AWT。此外,通过 \n
分隔行也不起作用。
我在 Linux 上运行:
Ubuntu 10.04
Kernel Linux 2.6.32-22-generic
GNOME 2.30.0
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK Server VM (build 14.0-b16, mixed mode)
任何帮助将不胜感激。
谢谢
I wrote an application and now I'm making a tray-icon. Now I want to set a multi-line tooltiptext to the tray-icon. But I don't know how. I know how to do this with Swing:
component.setToolTipText("<html>Line 1<br>Line2</html>");
But this doesn't work with AWT. Also serarating lines by \n
doesn't work.
I'm running on linux:
Ubuntu 10.04
Kernel Linux 2.6.32-22-generic
GNOME 2.30.0
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK Server VM (build 14.0-b16, mixed mode)
Any help would be very appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下代码为我生成了一个完美的多行工具提示:
也许是平台问题。你能给我们你的操作系统和jvm版本吗?似乎是一个错误,请参阅 suns bug 数据库。
The following code produced a perfectly fine multi line tooltip for me:
Maybe its a platform issue. Could you give us your OS and jvm version? Seems to be a bug, see inside suns bug database.
JToolTip
派生自JComponent
,但您可以使用仅Graphics
的方法自己模拟效果,如AlphaView
中所示> 此示例的类。JToolTip
derives fromJComponent
, but you can simulate the effect yourself usingGraphics
-only methods, as shown in theAlphaView
class of this example.