반응형
horizentally 수평 cf) Vbox Layout (related to Hbox Layout) :vertically
주로 child of another layout 으로 쓰임.
총코딩
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.HBox?>
<HBox fx:controller="sample.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="bottom_right"
style="-fx-border-color: red; -fx-border-width: 3; -fx-border-style: dashed"
spacing="25"> <!--위치 bottom_right/ border 추가(색,너비,스타일)/ spacing은 버튼간 간격-->
<padding>
<Insets bottom="10" right="10"/> <!--아래부터 10 오른쪽으로부터 10 간격-->
</padding>
<Button text="Okay" prefWidth="50"/> <!--prefWidth 버튼사이즈-->
<Button text="Cancel" prefWidth="90"/>
<Button text="Help" prefWidth="90"/>
</HBox>
Main
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 500, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
'JavaCode(review)' 카테고리의 다른 글
java fx - other layouts (0) | 2020.07.22 |
---|---|
java fx - BorderPane Layout (0) | 2020.07.21 |
java fx - GridPane Layout (0) | 2020.07.20 |
java fx - 글쓰기, 글색/진하게/크기 변경 등. (0) | 2020.07.20 |
collections challenge 종합 (0) | 2020.07.17 |