Skip to content

SWT Tutorial : Row Layout Example

package com.deveshcodelab.examples.swt;

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;

public class SWTSnippet12 extends Composite {
	public SWTSnippet12(Composite parent) {
		super(parent, SWT.NONE);
		RowLayout layout = new RowLayout(SWT.HORIZONTAL);
		setLayout(layout);
		for (int i = 0; i < 16; ++i) {
			Button button = new Button(this, SWT.NONE);
			button.setText("Sample Text "+i);
		}
	}

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, false));

		Composite composite = new SWTSnippet12(shell);
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *