JavaFX Day-Night Toggle Button - Custom Control implemented with JavaFX
-
Copy DayNightToggleButton.java and style.css in your Java FX Project. Be sure that you have a Java JDK installed which includes JavaFX.
-
Create your business related presentation model with a property for the day-night toggle button
private final BooleanProperty isDay = new SimpleBooleanProperty();
-
Create an instance of the day-night toggle button and pass it to your ui
// Declaration custom control private DayNightToggleButton dayNightToggleCustomControl; // Init custom control dayNightToggleCustomControl = new DayNightToggleButton();
-
Setup all relevant property bindings
dayNightToggleCustomControl.isToggledProperty().bindBidirectional(pm.isDayProperty());
-
Have fun 🎉