e850. laying out components in a row or column.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 25 行
TXT
25 行
A horizontal box container arranges the components left-to-right in their preferred sizes. The row of components are vertically centered.
// Create horizontal box container
Box box = new Box(BoxLayout.X_AXIS);
// Here is a another way to create a horizontal box container
box = Box.createHorizontalBox();
// Add components
box.add(component1);
box.add(component2);
A vertical box container arranges the components top-to-bottom aligned in their preferred sizes. The column of components are left-aligned.
// Create vertical box container
box = new Box(BoxLayout.Y_AXIS);
// Here is a another way to create a vertical box container
box = Box.createVerticalBox();
// Add components
box.add(component1);
box.add(component2);
Related Examples
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?