我有两个复合材料。第一个工作正常。我在Composite上调整大小并且行为正确。我在第二复合材料上做同样的事情,但它消失了。也许Composite内部的某些东西导致了这种行为?
代码:
@Override
public void createPartControl(final Composite parent) {
parent.setLayout(new RowLayout(SWT.VERTICAL));
final Composite composite = new Composite(parent, SWT.NONE);
composite.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
composite.setSize(parent.getSize());
}
});
composite.setLayoutData(new RowData(622, 34));
composite.setLayout(new GridLayout(3, false));
Label lblPolicy = new Label(composite, SWT.NONE);
lblPolicy.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblPolicy.setText("Policy:");
text = new Text(composite, SWT.BORDER);
GridData gd_text = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd_text.widthHint = 566;
text.setLayoutData(gd_text);
Label lblNewLabel = new Label(composite, SWT.NONE);
lblNewLabel.setText("X");
final Composite composite_1 = new Composite(parent, SWT.NONE);
//FIXME THIS RESIZE CAUSES EVERYTHING IN THE COMPOSITE TO DISAPPEAR
composite_1.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
composite_1.setSize(parent.getSize());
}
});
composite_1.setLayout(new GridLayout(2, false));
composite_1.setLayoutData(new RowData(624, 166));
Group grpGrid = new Group(composite_1, SWT.NONE);
grpGrid.setText("Grid");
GridData gd_grpGrid = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd_grpGrid.widthHint = 180;
gd_grpGrid.heightHint = 109;
grpGrid.setLayoutData(gd_grpGrid);
Label lblSegment = new Label(grpGrid, SWT.NONE);
lblSegment.setText("Segment:");
Label lblLifecycle = new Label(grpGrid, SWT.NONE);
lblLifecycle.setText("Lifecycle:");
Combo combo = new Combo(grpGrid, SWT.NONE);
Combo combo_1 = new Combo(grpGrid, SWT.NONE);
Group grpStore = new Group(composite_1, SWT.NONE);
grpStore.setText("Store");
GridData gd_grpStore = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd_grpStore.heightHint = 110;
gd_grpStore.widthHint = 201;
grpStore.setLayoutData(gd_grpStore);
Label lblServer = new Label(grpStore, SWT.NONE);
lblServer.setText("Server:");
Combo combo_2 = new Combo(grpStore, SWT.NONE);
Label lblNumber = new Label(grpStore, SWT.NONE);
lblNumber.setText("Number:");
text_1 = new Text(grpStore, SWT.BORDER);
new Label(composite_1, SWT.NONE);
Button btnSubmit = new Button(composite_1, SWT.NONE);
btnSubmit.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
btnSubmit.setText("Submit");
}
我试过为Composite中的每个元素取出setBounds。这没用。