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

how to display label on composite in swt?

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

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");

任何人都可以告诉我一个方法吗?

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

上设置布局