JAVA chapter17. javaFX. 17.4 JavaFX 컨테이너
JAVA/CONCEPT 2017. 12. 3. 19:58 |chapter17. javaFX
17.4 JavaFX 컨테이너
17.4.1 AnchorPane 컨테이너
// AnchorPane 컨테이너를 사용할 때는 SceneBulider를 사용하는게 좋다
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.layout.*?> <?import javafx.scene.control.*?> <AnchorPane xmlns:fx="http://javafx.com/fxml" prefHeight="150.0" prefWidth="300.0" > <children> <Label layoutX="42.0" layoutY="28.0" text="아이디" /> <Label layoutX="42.0" layoutY="66.0" text="패스워드" /> <TextField layoutX="120.0" layoutY="24.0" /> <PasswordField layoutX="120.0" layoutY="62.0" /> <Button layoutX="97.0" layoutY="106.0" text="로그인" /> <Button layoutX="164.0" layoutY="106.0" text="취소" /> </children> </AnchorPane> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | package sec04.exam01_anchorpane; 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(); primaryStage.setResizable(false); } public static void main(String[] args) { launch(args); } } | cs |
17.4.2 HBox와 VBox 컨테이너
|
17.4.3 BorderPane 컨테이너
|
17.4.4 FlowPane 컨테이너
|
17.4.5 TilePane 컨테이너
|
17.4.6. GridPane 컨테이너
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.layout.*?> <?import javafx.geometry.*?> <?import javafx.scene.control.*?> <GridPane xmlns:fx="http://javafx.com/fxml" prefWidth="300.0" hgap="10.0" vgap="10.0" > <padding> <Insets topRightBottomLeft="10.0"/> </padding> <children> <Label text="아이디" GridPane.rowIndex="0" GridPane.columnIndex="0"/> <TextField GridPane.rowIndex="0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" /> // 오른쪽 빈공간까지 확장 <Label text="패스워드" GridPane.rowIndex="1" GridPane.columnIndex="0"/> <TextField GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.hgrow="ALWAYS" /> <HBox GridPane.rowIndex="2" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.hgrow="ALWAYS" // GridPane.columnSpan은 컬럼 2개 병합 alignment="CENTER" spacing="20.0" > <children> <Button text="로그인" /> <Button text="취소" /> </children> </HBox> </children> </GridPane> | cs |
17.4.7 StackPane 컨테이너
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.layout.*?> <?import javafx.scene.image.*?> <StackPane xmlns:fx="http://javafx.com/fxml"> <children> <ImageView fitWidth="500" fitHeight="300" > // 가로비와 세로비 상관없이 고정 길이로 설정, 먼저 배치된것이 밑에 <image> <Image url="@images/snow.jpg" /> </image> </ImageView> <ImageView preserveRatio="true"> // 가로비와 세로비를 유지 <image> <Image url="@images/duke.gif" /> </image> </ImageView> </children> </StackPane> | cs |
'JAVA > CONCEPT' 카테고리의 다른 글
공백 (0) | 2017.12.30 |
---|---|
공백 (0) | 2017.12.30 |
JAVA chapter17. javaFX. 17.3 Java FX 레이아웃 (0) | 2017.12.03 |
JAVA chapter17. JavaFX. 17.1 JavaFX 개요. 17.2 JavaFX 애플리케이션 개발 시작 (0) | 2017.12.03 |
JAVA chapter14. 람다식. 14.6 메소드 참조 // 추가하기 (0) | 2017.12.02 |