BorderPane_SharedControls1 |
Code:/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package javafxtemplate1; import java.time.LocalDate; import javafx.application.Application; import javafx.geometry.Pos; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.DatePicker; import javafx.scene.control.Label; import javafx.scene.input.KeyEvent; import javafx.scene.layout.Border; import javafx.scene.layout.BorderPane; import javafx.scene.layout.FlowPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; /** * * @author Manas14 */ public class JavaFXTemplate1 extends Application { @Override public void start(Stage primaryStage) { BorderPane bPane = new BorderPane(); DatePicker datePicker = new DatePicker(); VBox gCenter = new VBox(); gCenter.setStyle("-fx-background-color: ORANGE;"); // top and bottom in bPane Label lTop = new Label("TOP"); lTop.setId("lTop"); Label lBottom = new Label("Bottom"); Label lLeft = new Label("Left"); Label lRight = new Label("Right"); Label lCenter = new Label("Center"); HBox hbox1 = new HBox();HBox hbox2 = new HBox(); VBox vbox1 = new VBox();VBox vbox2 = new VBox(); vbox1.setStyle("-fx-background-color: YELLOW;"); vbox2.setStyle("-fx-background-color: YELLOW;"); // hbox1.setStyle("-fx-background-color: RED;"); hbox1.getChildren().add(lTop); hbox1.setAlignment(Pos.CENTER);hbox1.setMinHeight(50); // hbox2.setStyle("-fx-background-color: GREEN;"); hbox2.getChildren().add(lBottom);//Ignored hbox2.setAlignment(Pos.CENTER);hbox2.setMinHeight(50); // vbox1.getChildren().add(lLeft); vbox1.setAlignment(Pos.CENTER); vbox1.setMinWidth(50); vbox2.getChildren().add(lRight); vbox2.setAlignment(Pos.CENTER); vbox2.setMinWidth(50); // gCenter.getChildren().addAll(lCenter,lBottom,datePicker); bPane.setTop(hbox1); bPane.setLeft(vbox1); bPane.setCenter(gCenter);bPane.setRight(vbox2) ; bPane.setBottom(hbox2); // Ignoerd // // datePicker.setOnAction(event -> { LocalDate date = datePicker.getValue(); lCenter.setText("Selected date: " + date); }); // Scene scene = new Scene(bPane, 300, 300); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } } |
BorderPane may have low priority on the shared UI controls. A label control "lBottom" as shown within Red rectangle below, was not loaded in HBox in the lower NODE, but loaded with VBox ("in green rectangle") in the middle NODE. |