[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Missing labels

I've written the following piece of code to demonstrate a problem we've been having:

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;

public class TestComp extends Composite {

	private Label labelTitle = null;
	private Label label = null;

	public TestComp(Composite parent, int style) {
		super(parent, style);
		initialize();
	}

	private void initialize() {
		GridData gridData = new GridData();
		gridData.horizontalSpan = 11;
		gridData.grabExcessHorizontalSpace = true;
		gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER;
		labelTitle = new Label(this, SWT.NONE);
		labelTitle.setText("Title Area");
		labelTitle.setLayoutData(gridData);
		
		GridData gridData2 = new GridData();
		gridData2.horizontalSpan = 1;
		gridData2.grabExcessHorizontalSpace = true;
		gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER;
		for(int i = 0; i < 22; i++) {
			Label label = new Label(this, SWT.NONE);
			label.setText("CELL");
			label.setLayoutData(gridData2);
		}
		
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 11;
		this.setLayout(gridLayout);
		setSize(new Point(385, 337));
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"


I would expect this code to produce a composite with a label spanning the top with "Title Area" centered and then 2 rows of 11 labels each saying "CELL".


However, what I get is the "Title Area" and no "CELL"s.

What am I missing to get what I expect?

Thanks in advance for any help,
Rick.