构造函数
1 | //布局约束 列约束 行约束 |
layoutConstraints 布局约束
hidemode
Sets the hide mode for the component. If the hide mode has been specified in the This hide mode can be overridden by the component constraint. The hide mode specified how the layout manager should handle a component that isn’t visible. The modes are:
0 - Default. Means that invisible components will be handled exactly as if they were visible.
1 - The size of the component (if invisible) will be set to 0, 0.
2 - The size of the component (if invisible) will be set to 0, 0 and the gaps will also be set to 0 around it.
3 - Invisible components will not participate in the layout at all and it will for instance not take up a grid cell.
Example: “hidemode 1”
wrap+数字
指定第几个组件后进行换行,如:
wrap 2表示第二个组件后换行insets+数字
指定与边界的距离,如:
insets 10表示四边均为10,insets 1 2 3 4表示顶部,左侧,下部,右侧的距离
colConstraints 列约束 和 rowConstraints 行约束
1 | MigLayout layout = new MigLayout("fillx", "[right]rel[grow,fill]", "[]10[]"); |
如上
grow
y/x方向按上一级宽度进行延伸.注意如果此处不添加
grow,那么在添加组件时使用growy或growx将无效数字+!
表面该单元高度/宽度固定为数字大小.如:
40!数字:数字:数字
分别表示: 最小距离:最佳距离:最大距离.如
10:30:40,也可以::40,表示最大40,其它无限制,同理:10::,:30:top/bottom/center
垂直方向对齐方式
center/right/left
水平方向对齐方式
添加组件
1 | panel.add(component,""); |
第二个字符串参数可使用以下约束:
growx/growy
在水平/垂直方向延伸.前提布局约束有已开启延伸.如
panel.add(button,"growx")span
span占用本行所有单元格,span 2占用横向两个单元格,span 2 3占用横向2个单元格和纵向3个单元格wrap
添加本组件后进行换行
gapleft/gapright/gaptop/gapbottom
指定四周的间隔
split
split 2将该单元格分成两个单元格w 数字:数字:数字
指定宽度属性,如
w 10:20:30,w 30!,w ::30等h 数字:数字:数字
指定高度属性,如
h 10:20:30,h 30!,h ::30等