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

Updated setGraphic(File) method #46

Closed EasyG0ing1 closed 2 years ago

EasyG0ing1 commented 2 years ago

The updateGraphic(File file) method when used with Java 18, throws an exception, because when loading a JavaFX Image from a file path, it has to be preceded with the word "file:" - and I can't remember if that is also true of Java 1.8, but I tend to think it's not.

So I updated the method to catch the error if it's thrown, then it will prepend the path to the file with "file:" and then it loads the image and keeps moving along...

Tested it in GistFX and it works properly.

EasyG0ing1 commented 2 years ago

Updated the PR which leaves the original setGraphic method intact, and instead, I added two overloaded methods:

setGraphic(File file, int iconWidth, int iconHeight)
setGraphic(String URLString, int iconWidth, int iconHeight)

Which allow passing in a file object or a String of the URL along with desired width and height.

EasyG0ing1 commented 2 years ago

I have significantly changed this pull request, so I am closing it and opening a different one.