“This is the 26th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”
Line box layout
1. The static method createHorizontalBox() of the Box class gets a Box with a row Box layout
Box, Box;
• box = box. CreateHorizontalBox (); 2. The top edges of the components added to the container are on the same level
Column box layout
1. The static method createVerticalBox() of the Box class gets a Box container with a columnar Box layout
Box, Box;
• box = box. CreateVerticalBox ();
2. The left edge of the added components in the column box layout container is on the same vertical line
Box layout manager
1. If you want to control the distance between components in a box layout container, you need to use horizontal or vertical bracing
CreateHorizontalStrut (int Width); createHorizontalStrut(int Width)
CreateVertialStrut (int height); createVertialStrut(int height)
Border layout manager
BorderLayout is the default layout manager for Windows, JFrame, and JDialog. The border layout manager divides the window into five regions: North, South, East, West, and Center. North, representing North, will occupy the upper part of the panel; Soufe, for South, will occupy the lower part of the panel; East, for East, will occupy the right side of the panel; West, for West, will occupy the left side of the panel; The middle area Center is the area left after the east, south, west, and north are filled, as shown in Figure 1.
Tip: The border layout manager does not require all regions to have components. If the surrounding regions (North, South, East, and West regions) do not have components, the Center region will fill them. If more than one component is added to a single zone, the later component overrides the original component, so only the last component added is shown in the zone.
The BorderLayout layout manager is constructed as follows.
- BorderLayout() : Creates a Border layout with no gaps between components.
- BorderLayout(int hGap,int vGap) : Creates a Border layout where Hgap represents the horizontal spacing between components; Vgap represents the longitudinal interval between components, in pixels.