max*_*mus 3 java layout user-interface swing gridbaglayout
当您使用组布局时,您可以通过以下方式设置所有间隙:
setAutoCreateGaps(true);
setAutoCreateContainerGaps(true);
Run Code Online (Sandbox Code Playgroud)
有相同的功能GridBagLayout吗?
在 GridBagLayout 中,使用 GridBagConstraints 您可以使用以下属性设置间隙;
GridBagConstraints.ipadx,GridBagConstraints.ipady:指定布局内组件的内部填充。
GridBagConstraints.insets:指定组件的外部填充。
GridBagConstraints.weightx,GridBagConstraints.weighty:用于确定如何分配空间。
例如:
pane.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.ipady = 40; //make this component tall
c.ipadx = 10; //make this component wide
c.anchor = GridBagConstraints.PAGE_END; //bottom of space
c.insets = new Insets(10,0,0,0); //top padding
c.gridx = 1; //first column
c.gridy = 2; //third row
c.gridwidth = 2; //2 columns wide
c.weightx = 0.5; //increase horizontal space
c.weighty = 1.0; //increase vertical space
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5212 次 |
| 最近记录: |