This article is the 17th day article of SLP KBIT Advent Calendar 2018.
This article introduces a container that I wasn't sure about when I started using JavaFX and SceneBuilder. There are many people who are touching Java in the circle these days, so I hope it will help you when creating GUI applications.
The one in this area. It is the basis for arranging objects such as buttons. It is also possible to place the container inside the container, and it is possible to create a more complicated layout by combining them.
Pane The simplest container. You can place the object anywhere you like.
AnchorPane You can fix the distance from the frame of AnchorPane to the objects installed in it.
Prepare a button that is anchored in the right frame of AnchorPane and a button that is not anchored anywhere. In this state, if you enlarge the screen size to the right, In this way, the anchored button moves at a distance from the right frame.
VBox VBox arranges objects vertically from the top side by side. It is possible to match the width of the object to the width of VBox, and you can make detailed settings when the screen size is changed. You can make the layout easier to see by setting the size and margins for each object.
HBox HBox arranges objects horizontally from left to VBox. It basically works the same as VBox.
FlowPane FlowPane lays out objects horizontally like HBox, but arranges them so that they wrap when they come to the far right. Like VBox, it can be laid out vertically.
BorderPane BorderPane places objects in the top, left, right, bottom, and center positions. Objects placed one above the other will be resized to their priority height, expanding the width of the BorderPane. Objects placed on the left and right are resized to their priority width and their vertical length is extended. Centered objects are resized to fill the entire available space in the center. Only one object can be placed in each location. If you want to place multiple objects, you need to place another container.
GridPane GridPane places objects in squares consisting of rows and columns. It is also possible to place it across multiple squares.
This time, I introduced a container for arranging objects. However, there are other containers as well. Also, if I have a chance, I would like to explain in more detail how to use it and introduce other containers.
Recommended Posts