ThatGuy343
ThatGuy343

Reputation: 2424

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? This is specifically on OSX.

Upvotes: 4

Views: 1232

Answers (1)

Trevi Awater
Trevi Awater

Reputation: 2407

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);

Upvotes: 7

Related Questions