Java/17. JavaFX
Day 25 : JavaFX 컨테이너 - BorderPane 컨테이너
pancakemaker
2021. 11. 23. 10:33
BorderPane 컨테이너
: top, bottom, left, right, center 셀에 컨트롤을 배치
: top, bottom, left, right에 셀을 배치하지 않으면, center에 배치된 컨트롤이 확장
: 각 셀에는 하나의 컨트롤 또는 컨테이너만 배치할 수 있음
BorderPane 컨테이너
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.*?>
<BorderPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="200.0" prefWidth="300.0">
<top>
<ToolBar>
<items>
<Button text = "Button" />
<Button text = "Button" />
</items>
</ToolBar>
</top>
<center>
<TextArea />
</center>
<bottom>
<BorderPane>
<center>
<TextField />
</center>
<right>
<Button text = "Button" />
</right>
</BorderPane>
</bottom>
</BorderPane>
BorderPane 컨테이너 실행
package sec04.exam03_borderpane;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class AppMain extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("root.fxml"));
Scene scene = new Scene(root);
primaryStage.setTitle("AppMain");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}