[英]System tray text instead of icon
How can I display text in the system tray instead of an icon? 如何在系统托盘中显示文本而不是图标? I want to display a percentage for example.
我想显示百分比例如。
final TrayIcon trayIcon = new TrayIcon(createImage("image.png", "tray icon"));
The code above is to set an icon, but how can I set text such as 100%
to display in the system tray? 上面的代码是设置一个图标,但如何设置
100%
文本显示在系统托盘中? This is specifically on OSX. 这是专门针对OSX的。
You can draw the text onto an image, this does the job although you are still using an image. 您可以将文本绘制到图像上,虽然您仍在使用图像,但这可以完成工作。 I don't think there is an other way to do it.
我认为没有其他办法可以做到这一点。
BufferedImage image = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = image.createGraphics();
g2d.drawString("100%", x, y);
g2d.dispose();
trayIcon.setImage(image);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.