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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With