如何在swt中显示复合材料上的标签?

时间:2015-09-30 06:48:01

标签: eclipse swt eclipse-rcp rcp

我想在复合材料上显示标签。我添加了标签,但我看不到显示。我的代码如下:

GridLayout parentLayout = new GridLayout(1, true);
parent.setLayout(parentLayout);

Composite filterComposite = new Composite(parent, SWT.NONE);
GridData filterCompositeData = new GridData();
filterCompositeData.verticalAlignment = GridData.FILL;
filterCompositeData.horizontalSpan = 2;
filterCompositeData.grabExcessHorizontalSpace = true;
filterCompositeData.grabExcessVerticalSpace = true;
filterCompositeData.horizontalAlignment = GridData.FILL;
filterComposite.setLayoutData(filterCompositeData);

Label l1 = new Label(filterComposite, SWT.NONE);
Text t1 = new Text(filterComposite, SWT.NONE);

l1.setText("xxxxxxxxxxx");

有人能告诉我这样做的方法吗?

1 个答案:

答案 0 :(得分:1)

您尚未在filterComposite上设置布局 - 您必须在每个Composite上设置布局