package hellofx; import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class GUI018 extends Application { int l = 50; @Override public void start(Stage mainStage) throws Exception { BorderPane bp = new BorderPane(); Rectangle r = new Rectangle(0,0,l,l); bp.setCenter(r); HBox hb = new HBox(); hb.setAlignment(Pos.CENTER); hb.setPadding(new Insets(10,10,10,10)); hb.setSpacing(10); Button clickBut = new Button("Bigger"); clickBut.setOnAction((e) -> { l += 5; r.setWidth(l); r.setHeight(l); }); hb.getChildren().add(clickBut); Button noClickBut = new Button("Smaller"); noClickBut.setOnAction((e) -> { l -= 5; r.setWidth(l); r.setHeight(l); }); hb.getChildren().add(noClickBut); bp.setBottom(hb); Scene sc = new Scene(bp, 500, 500); mainStage.setScene(sc); mainStage.show(); } public static void main(String[] args) { Application.launch(args); } }