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? This is specifically on 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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.