dustinkredmond / FXTrayIcon

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

running on mac os , but get unexpected result #7

Closed littleboyonearth closed 3 years ago

littleboyonearth commented 3 years ago

hi, @dustinkredmond

I just run the RunableTest.java ,but the notifications are not as expected

image

the notification popup displays just like a normal window. with min, max, close, and a button on it.

I have seen the posted screen shot of other guys, and it is just ok https://github.com/dustinkredmond/FXTrayIcon/issues/2

here is my mac os info: image

hope that I have described clear

littleboyonearth commented 3 years ago

jdk: 1.8.0_281

dustinkredmond commented 3 years ago

@littleboyonearth The display methods simply wrap calls to AWT's TrayIcon instance methods, so the real implementation is done by AWT.

That being said, I will take a look at this and see if there is some sort of workaround. FXTrayIcon pretty much expects AWT to behave as documented, but in this case it isn't.

littleboyonearth commented 3 years ago

@dustinkredmond I'm very appreciate your help!

dustinkredmond commented 3 years ago

@littleboyonearth It seems as though there's no good workaround that I'm able to find at the moment. I will leave this issue open to do some more research and see if any other folks may know how to handle this. In the meantime, my library FXAlert helps to build notifications using pure JavaFX and it does not rely on AWT. It may be a feasible alternative in the meantime. Thanks for opening the issue!

EasyG0ing1 commented 3 years ago

I just ran the demo in a Windows 10 virtual machine, and it was immediately obvious to me that AWT is forced to implement the alert dialogue using two completely different methods. In windows, the dialog uses whatever its called in Windows where the alert slides out from the side of the window like what you see when you have a message about updates, or opening potentially unsafe programs etc. I also realized that the way Windows does the system tray it very different from Mac. For example in Windows, when the system tray gets full, it gives you an arrow that you can click on to see those icons that could not be displayed because there are too many in the system tray. MocOS does not have any mechanism for that. If the icons in the tray become too numerous, the menus from whichever program you have running and active win the priority for that real estate and the tray icons simply get hidden under the programs menu structure. This might explain why double-clicking a tray icon in Windows works when it does not work on a Mac.

Hiding the title bar on an alert message is possible with the JavaFX version of an alert, but apparently, that is not an option with an AWT alert which is what is being used in FXTray Icon when its run on a Mac.

The only MAC equivalent to the Windows-style alert that AWT uses would be Growl. But obviously, AWT would most likely not be "Growl aware" since that is a third party program that a user chooses to install and is not native to MacOS.

dustinkredmond commented 3 years ago

@EasyG0ing1 I merged PR #8 which should fix this, thanks for your contribution! @littleboyonearth I will publish an updated version to Maven Central by the end of the week, this should fix the issue you were having, thanks for opening the Issue! 👍🏻

littleboyonearth commented 3 years ago

thanks both of you guys, so quick and excellent!

dustinkredmond commented 3 years ago

@littleboyonearth & @EasyG0ing1 I pushed release 2.7.0 to Maven Central this morning which fixes the issue. @EasyG0ing1, do you know if the osascript allows for setting an icon?

EasyG0ing1 commented 3 years ago

@dustinkredmond Unfortunately, there is no option to change the icon with the osascript call. I looked deeply for that capability, but the only way to get the sliding alert is with this AppleScript command:

display notification v : Display a notification. At least one of the body text and the title must be specified. display notification [text] : the body text of the notification [with title text] : the title of the notification (default is the name of the calling application). [subtitle text] : the subtitle of the notification [sound name text] : the name of the sound to play

Whereas a display dialog does have the option of changing the icon, but that is a standard popup window just like AWT did before this update.