Desktop gadget programs have common functions such as…
- Transparent Window
- no border, no title-bar, transparent background
- Move by mouse dragging
- Resize by mouse wheel plus some key (e.g. Ctrl key)
- Popup menu to close window
- Save last position and size, load such status at next start.
It is boilerplate code to implement these common functions in each gadget
program.
This JavaFX Gadget Support Libraries provide common gadget functions to your
gadget program without boilerplate code.
This is a sample JavaFX application using JavaFX Gadget Support Libraries.
Only 1-line code in your application is needed for gadget common functions.
public class TinyGadgetApp extends Application { @Override public void start(Stage stage) throws Exception { TinyGadgetSupport.of(stage, Preferences.userNodeForPackage(this.getClass())); Parent root = FXMLLoader.load(getClass().getResource("TinyGadgetView.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); } }
JavaFX Window with StageStyle.TRANSPARENT shows the application on the task bar.
JavaFX Window with StageStyle.UTILITY doesn’t show the application on the task bar.
But current JavaFX Library has no function both TRANSPARENT and UTILITY.
There is a workaround to use taskbarless TRANSPARENT window.
- primary stage with UTILITY
- secondary stage with TRANSPARENT
- make primary stage invisible
public class TinyGadgetApp extends Application { @Override public void start(Stage primaryStage) throws Exception { var support = TinyGadgetSupport.ofTaskbarless(primaryStage); var root = ... var scene = new Scene(root); var stage = support.getTransparentStage(); stage.setScene(scene); stage.show(); }