import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ProgressBar; import javafx.scene.control.ProgressIndicator; import javafx.scene.layout.GridPane; import javafx.stage.Stage; public class BindingsBsp3 extends Application { private static final double INITIAL_STAND = 0.3; @Override public void start(Stage primaryStage) { final Konto konto = new Konto(); konto.setStand(INITIAL_STAND); Button incButt = new Button("+0.01"); incButt.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { konto.setStand(konto.getStand() + .01); } }); Button decButt = new Button("-0.01"); decButt.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { konto.setStand(konto.getStand() - .01); } }); ProgressBar pb = new ProgressBar(INITIAL_STAND); pb.progressProperty().bind(konto.standProperty()); ProgressIndicator pi = new ProgressIndicator(INITIAL_STAND); pi.progressProperty().bind(konto.standProperty()); GridPane grid = new GridPane(); grid.add(incButt, 0, 0); grid.add(decButt, 1, 0); grid.add(pb, 0, 1); grid.add(pi, 1, 1); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(10)); Scene scene = new Scene(grid); primaryStage.setScene(scene); primaryStage.setTitle("Binding-Beispiel"); primaryStage.show(); } public static void main(String[] args) { launch(args); } }