GridLayout使用

在一个Composite放一个Label和一个Text, 其中Text自动填满剩余的水平space:

Composite permissionComposite = toolkit.createComposite(actionDetailComposite);
final GridLayout gl_permissionComposite = new GridLayout(2, false);
permissionComposite.setLayout(gl_permissionComposite);
[color=red][b]permissionComposite.setLayoutData(new GridData (GridData.FILL_HORIZONTAL));[/b][/color]

Label permissionLabel = new Label(permissionComposite, SWT.NONE);
permissionLabel.setText("permission");
GridData gd_permissionLabel = new GridData(GridData.FILL_BOTH);
gd_permissionLabel.horizontalSpan = 2; //占2格
permissionLabel.setLayoutData(gd_permissionLabel);

Label typeLabel = new Label(permissionComposite, SWT.NONE);
typeLabel.setText("type:");
Text typeText = new Text(permissionComposite, SWT.BORDER);
[color=red]typeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));[/color]

如果其中父composite(actionDetailComposite)有两格new GridLayout(2,false),在某子composite来定义两格,实现上述功能,需将父composite定义如下:
GridData gb_actionDetail = new GridData(SWT.FILL, SWT.FILL, true, true);
actionDetailComposite.setLayoutData(gb_actionDetail);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值