BorderPane †
- 上、右、左、中央、下といったボックスレイアウトを構築する
サンプル BorderPaneでPaneを配置する例
package sample; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; import javafx.stage.Stage; public class SampleBorderPane extends Application { /** * Initialize stage and start scene. * * @param primaryStage * @throws Exception */ @Override public void start(Stage primaryStage) throws Exception { BorderPane bpane = new BorderPane(); // Labels that arrange in the border pane. Pane paneTop = new Pane(); paneTop.setStyle("-fx-background-color: black"); paneTop.setPrefSize(Pane.USE_COMPUTED_SIZE, 50); Pane paneLeft = new Pane(); paneLeft.setStyle("-fx-background-color: red"); paneLeft.setPrefSize(50, Pane.USE_COMPUTED_SIZE); Pane paneRight = new Pane(); paneRight.setStyle("-fx-background-color: green"); paneRight.setPrefSize(50, Pane.USE_COMPUTED_SIZE); Pane paneCenter = new Pane(); paneRight.setStyle("-fx-background-color: yellow"); paneCenter.setPrefSize(Pane.USE_COMPUTED_SIZE, 50); Pane paneBottom = new Pane(); paneBottom.setStyle("-fx-background-color: blue"); paneBottom.setPrefSize(Pane.USE_COMPUTED_SIZE, 50); // Set labels. bpane.setTop(paneTop); bpane.setLeft(paneLeft); bpane.setRight(paneRight); bpane.setCenter(paneCenter); bpane.setBottom(paneBottom); // Create a scene Scene scene = new Scene(bpane, 300, 300); primaryStage.setScene(scene); // Show window. primaryStage.show(); } /** * Launch application. * * @param args */ public static void main(String[] args) { launch(args); } }
補足
- 上、右、左、下、中央にそれぞれ色付きのPaneを配置している。