import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.stage.Stage; public class BindingsBsp1 extends Application { @Override public void start(Stage primaryStage) { final Konto konto = new Konto(); konto.setStand(0); Button incButt = new Button("+1"); final Label label = new Label(new Double(konto.getStand()).toString()); label.setMinSize(incButt.getMinWidth(), incButt.getMinHeight()); label.setAlignment(Pos.CENTER); konto.standProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue o, Object oldVal, Object newVal) { label.setText(new Double(konto.getStand()).toString()); } }); incButt.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { konto.setStand(konto.getStand() + 1); } }); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setVgap(10); grid.add(label, 0, 0); grid.add(incButt, 0, 1); Scene scene = new Scene(grid, 150, 100); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }