2015-09-30 23 views
0

我想在复合上显示一个标签。我添加了标签,但我无法看到显示。我的代码如下:如何在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"); 

任何人都可以告诉我一种方法来做到这一点吗?

回答

1

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