【发布时间】:2023-04-05 13:57:02
【问题描述】:
当我在ViewPart 中嵌入Composite 控件时,会在文本框和按钮之间添加垂直边距/填充(按钮是另一个组合的一部分),如附图所示。
我怎样才能删除它?
public class View extends ViewPart {
public static final String ID = "xyyx.view";
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout(1, false);
parent.setLayout(layout);
Text infoText = new Text(parent, SWT.BORDER);
GridData gridDataInfo = new GridData();
gridDataInfo.horizontalSpan = 1;
gridDataInfo.grabExcessHorizontalSpace = true;
gridDataInfo.horizontalAlignment = GridData.FILL;
infoText.setLayoutData(gridDataInfo);
new NewComposite(parent, SWT.NONE);
}
public class NewComposite extends Composite{
public NewComposite(Composite parent, int style) {
super(parent, style);
GridLayout layout = new GridLayout(1, false);
setLayout(layout);
Button btn = new Button(parent, SWT.PUSH);
btn.setText("Button");
}
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
}
【问题讨论】: