dustinkredmond / FXTrayIcon

Tray Icon implementation for JavaFX applications. Say goodbye to using AWT's SystemTray icon, instead use a JavaFX Tray Icon.
MIT License
324 stars 25 forks source link

showMessage() title of the notification window #73

Closed valimaties closed 11 months ago

valimaties commented 1 year ago

Hi. All showMessage() methods implemented in this project displays a notification message of different types (info, warning, error..). But the title of that notification is "OpenJDK Platform binary" which is not a good idea to show it, it's annoing. I want to change it to my app's name. How can we change that title?

Title

EasyG0ing1 commented 1 year ago

@valimaties I did a little digging into this and found out that the name of the JDK that is being displayed is inserted by Windows before the message is shown. Apparently the awt object is simply utilizing a means of displaying the message that is provided by Windows and Windows injects that information to be shown most likely as a means of identifying the source of the message to the user.

I can't think of a way to override that or even alter what that portion of the message shows since its happening outside of the scope of the running Java code, the code would have no way of manipulating it.

mrgreywater commented 1 year ago

You may be able to create a custom .exe for windows with a tool like https://winrun4j.sourceforge.net/ . That way windows doesn't see your application as java.exe, but your own custom independent application.

EasyG0ing1 commented 1 year ago

@mrgreywater I just compiled a test app for Windows using the Java Packager Maven plugin which uses winrun4J to package apps for Windows and it still gave me a message about the Java runtime environment ... not sure if that's something that can be altered by leveraging the winrun4J program directly or not, but I think all in all, Windows will be putting SOMETHING in that spot and it figures out what that something is by identifying - some how - the name of the resource that called its message service.

dustinkredmond commented 1 year ago

I'm pretty sure we can use TrayIcon.MessageType.NONE to get rid of this, but I think that makes us lose the pretty "Info", "Warning", "Error" icons that are built in.

I think this StackOverflow post provides some additional useful info: Link here

Question is, how should we handle it as far as a library is concerned?

EasyG0ing1 commented 1 year ago

@dustinkredmond Well right now, the standard showMessage() call in the library (4.1.0 version) does set the message type to .NONE, and I tested it on a Windows 11 VM after putting in a println in that method to let me know for sure that was the method being executed and as you can see, it still gives the name of the Java platform...

I even compiled it to an .exe and I got the same behavior so I'm not quite sure what that StackExchange response is referring to unless the behavior he is describing was somewhat that was possible to modify with that method in the past but maybe it no longer works ... or maybe it deosn't work with Windows 11 and it might work with 10... I dunno...

It did, however pick up the Icon from the TrayIcon object though it's presented fairly small and would hardly stand out to most people.

Screenshot 2023-02-12 at 7 36 04 PM
dustinkredmond commented 11 months ago

Seems to be platform-dependent behavior. I bet this varies from JDK vendor to another as well. I don't think there's anything for us to do to correct this from our side, so unfortunately, I'm going to have to close this issue and leave it at that. If someone can find another angle of attack, that would be awesome, but reserving calling native code, I'm not sure of a way to make this behavior uniform.