I have a filter composite in parent. My example image is here:
我在父级中有一个过滤器组合。我的示例图片在这里:
I want to add a group out of this filter composite. My example code is below:
我想从这个过滤器组合中添加一个组。我的示例代码如下:
// create parent layout
GridLayout parentLayout = new GridLayout(1, true);
parent.setLayout(parentLayout);
// design filter composite layout
Group grp = new Group(parent, SWT.NONE);
RowLayout grdLay = new RowLayout();
GridData grdData = new GridData();
grp.setLayoutData(grdData);
grp.setLayout(grdLay);
Composite grpComp = new Composite(grp,SWT.NONE);
GridData gdData = new GridData();
RowLayout grplayout = new RowLayout();
grpComp.setLayout(grplayout);
grpComp.setLayoutData(gdData);
Composite filterComposite = new Composite(grpComp, SWT.NONE);
GridData gd_filterComposite = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gd_filterComposite.widthHint = 1611;
gd_filterComposite.heightHint = 42;
filterComposite.setLayoutData(gd_filterComposite);
RowLayout filterCompositeLayout = new RowLayout();
filterCompositeLayout.type = SWT.VERTICAL;
filterCompositeLayout.marginHeight = 5;
filterCompositeLayout.center = true;
filterCompositeLayout.fill = true;
filterCompositeLayout.justify = true;
filterCompositeLayout.wrap = true;
filterComposite.setLayout(filterCompositeLayout);
filterCompositeLayout.spacing = 20;
But I had an error. My error image is here:
但我有一个错误。我的错误图片在这里:
How can I achive this? Can anybody give some advice? Thank you.
我怎么能得到这个?有人可以提一些建议吗?谢谢。
1 个解决方案
#1
1
For controls which are part of a RowLayout the layout data must be RowData.
对于属于RowLayout的控件,布局数据必须是RowData。
So
RowData gdData = new RowData();
because grpComp
is part of the RowLayout
set on grp
因为grpComp是grp上RowLayout集的一部分
and similarly the filterComposite
layout data should be RowData
.
类似地,filterComposite布局数据应该是RowData。
You must always match a control's layout data to the layout of the Composite which contains the the control.
您必须始终将控件的布局数据与包含该控件的Composite的布局相匹配。
#1
1
For controls which are part of a RowLayout the layout data must be RowData.
对于属于RowLayout的控件,布局数据必须是RowData。
So
RowData gdData = new RowData();
because grpComp
is part of the RowLayout
set on grp
因为grpComp是grp上RowLayout集的一部分
and similarly the filterComposite
layout data should be RowData
.
类似地,filterComposite布局数据应该是RowData。
You must always match a control's layout data to the layout of the Composite which contains the the control.
您必须始终将控件的布局数据与包含该控件的Composite的布局相匹配。