import javafx.application.Application; import javafx.beans.InvalidationListener; import javafx.beans.Observable; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class Main extends Application { public static void main(String[] args) { launch(args); } SimpleBooleanProperty bool = new SimpleBooleanProperty(true); { bool.addListener(new ChangeListener() { public void changed(ObservableValue val, Boolean oldVal, Boolean newVal) { System.out.println("Heard a change..."); } }); bool.addListener(new ChangeListener() { public void changed(ObservableValue val, Boolean oldVal, Boolean newVal) { System.out.println("Heard a change 2..."); } }); bool.addListener(new InvalidationListener() { public void invalidated(Observable val) { System.out.println("Invalidated 1"); } }); bool.addListener(new InvalidationListener() { public void invalidated(Observable val) { System.out.println("Invalidated 2"); } }); } boolean toggle = true; @Override public void start(final Stage stage) { HBox root = new HBox(); final Scene scene = new Scene(root); stage.setWidth(300); stage.setHeight(200); stage.setScene(scene); final VBox box = new VBox(40); Button butt = new Button("Toggle"); butt.setOnAction(new EventHandler() { public void handle(ActionEvent e) { toggle = !toggle; bool.getValue(); bool.setValue(toggle); } }); box.getChildren().addAll(butt); root.getChildren().addAll(box); stage.setVisible(true); } }