AWT's TrayIcon
class has a method called displayMessage
that shows a native OS message that in Windows 10 looks like this:
when called like this:
Image image = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/isotype.png"));
final TrayIcon trayIcon = new TrayIcon(image, appName());
trayIcon.displayMessage("Caption", "Text text text", TrayIcon.MessageType.INFO);
How do I customize the string "Java(TM) Platform SE binary". When I build a self-contained exe for my application, it instead reads "Blah.exe" while I'd prefer it if reads just "Blah".
To package the application I'm using the JavaFX toolchain through the excellent JavaFX-Gradle-Plugin.
One workaround is to use TrayIcon.MessageType.NONE
. In this case you won't get the last line at all, but you won't get any INFO, WARNING or ERROR icon either.
But the good thing is that you can get your application icon in the displayed message. If you create the TrayIcon
with some image like TrayIcon trayIcon = new TrayIcon(image, "Tooltip")
and then package your application with JavaFX-Gradle-Plugin, displayMessage
method will reuse this image and you will get something like this:
The behaviour of TrayIcon is platform dependent. On a Mac, there's no such thing as "Java(TM) Platform SE binary", nor the executable.
If you want to change the behaviour on your platform, I guess you could play with awt.toolkit. See https://docs.oracle.com/javase/8/docs/api/java/awt/Toolkit.html#getDefaultToolkit--
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