Ch6GridSpanComposite.java Source code

Java tutorial

Introduction

Here is the source code for Ch6GridSpanComposite.java

Source

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;

public class Ch6GridSpanComposite extends Composite {

    public Ch6GridSpanComposite(Composite parent) {
        super(parent, SWT.NONE);

        GridLayout layout = new GridLayout(3, false);
        setLayout(layout);

        Button b = new Button(this, SWT.NONE);
        b.setText("Button 1");

        b = new Button(this, SWT.NONE);
        b.setText("Button 2");
        b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        b = new Button(this, SWT.NONE);
        b.setText("Button 3");

        Text t = new Text(this, SWT.MULTI);
        GridData data = new GridData(GridData.FILL_BOTH);
        data.horizontalSpan = 2;
        data.verticalSpan = 2;
        t.setLayoutData(data);

        b = new Button(this, SWT.NONE);
        b.setText("Button 4");
        b.setLayoutData(new GridData(GridData.FILL_VERTICAL));

        b = new Button(this, SWT.NONE);
        b.setText("Button 5");
        b.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    }
}