eponymous
eponymous

Reputation: 2228

how to display label on composite in swt?

I want to display a label on composite. I added label but I can not see on display. My code is below:

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

Can anybody show me a way to do this?

Upvotes: 0

Views: 506

Answers (1)

greg-449
greg-449

Reputation: 111142

You have not set a Layout on filterComposite - you must set a layout on every Composite

Upvotes: 1

Related Questions