浏览 5269 次
锁定老帖子 主题:GridLayout使用
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-05-22
最后修改:2009-05-22
Composite permissionComposite = toolkit.createComposite(actionDetailComposite); final GridLayout gl_permissionComposite = new GridLayout(2, false); permissionComposite.setLayout(gl_permissionComposite); permissionComposite.setLayoutData(new GridData (GridData.FILL_HORIZONTAL)); 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); typeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 如果其中父composite(actionDetailComposite)有两格new GridLayout(2,false),在某子composite来定义两格,实现上述功能,需将父composite定义如下: GridData gb_actionDetail = new GridData(SWT.FILL, SWT.FILL, true, true); actionDetailComposite.setLayoutData(gb_actionDetail); 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2009-05-22
rainShare 写道 在一个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); |
|
返回顶楼 | |