【发布时间】:2019-06-25 13:16:49
【问题描述】:
我尝试创建自己的 FieldEditor(因为我必须动态填充组合框值)。所以我的课扩展了'FieldEditor'。我的首选项页面需要 3 个这样的字段(第二、第三和第四字段编辑器;“选择内核”)。
显然布局出了点问题。所有字段都应该看起来像第三个字段 - 使用完整的空间。
@Override
protected void adjustForNumColumns(int numColumns) {
((GridData) c_top.getLayoutData()).horizontalSpan = numColumns;
}
@Override
protected void doFillIntoGrid(Composite parent, int numColumns) {
/* Layout comments:
*
* component are sequentially filled into numColumns
* by default each component will use 1 column
* GridData can be set to use more that one columns
*/
GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
gd.horizontalSpan = numColumns;
c_top = parent;
c_top.setLayoutData(gd);
c_group = new Composite(c_top, SWT.BORDER);
GridLayout newgd = new GridLayout(2, false);
c_group.setLayout(newgd);
c_group.setLayoutData(gd);
// kernel spec combo
Label comboLabel = new Label(c_group, SWT.NONE);
comboLabel.setText("Select kernel");
gd = new GridData(SWT.LEFT, SWT.TOP, false, false);
gd.horizontalSpan = numColumns - 1;
comboLabel.setLayoutData(gd);
c_kernelCombo = new Combo(c_group, SWT.READ_ONLY);
gd = new GridData(SWT.FILL, SWT.TOP, true, false);
//gd.horizontalSpan = 1;
c_kernelCombo.setLayoutData(gd);
}
我什至在不使用组的情况下尝试了一个更简单的布局,但我所有的字段编辑器只使用了网格的 2 个单元格(其他字段编辑器给出的 3 列看起来有点滑稽。
我不知道如何解决它。有人可以帮忙吗?
【问题讨论】:
标签: eclipse grid-layout preferences