Closed atelechev closed 3 years ago
@atelechev Thank you for the pull request. I appreciate your contribution; at first glance, this looks perfect. I will further review (and most probably merge). Again, thank you!
Looks great! Merging this now. Will try to add it to a release in the near future.
Hello Dustin,
Thank you very much for this compact and useful
FXTrayIcon
project!I'm going to use your lib in my project and would like to suggest a minor adjustment for the API of the
FXTrayIcon
object.Use Case
The use case is the following: there are several images pre-loaded from local files and stored in an object. These images will be used as tray icons set in runtime, depending on the state of my application.
Current Implementation
The current implementation of
FXTrayIcon
allows to instantiate it only with image file paths typed asURL
.Changing the icon in runtime is possible with
javafx.scene.image.Image
type only, but the target type is the good oldjava.awt.Image
.Suggested Changes
Add a constructor which takes
java.awt.Image
as an argument with pre-loaded image data. The two existing constructors withURL
s can be chained to it.Add an overload for the
setGraphic
method, which takes ajava.awt.Image
as its arg. The existingsetGraphic
is chained to this overload, because it was transforming a FX image instance into an AWT image.Other changes: flattened the constructor logic by extracting the methods
ensureSystemTraySupported()
,attemptSetSystemLookAndFeel()
andloadImageFromFile()
, making the constructor shorter and simpler.