Skip to content

SWT Tutorial : List Example

package com.deveshcodelab.examples.swt;

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

public class SWTSnippet16 extends Composite {
	public SWTSnippet16(Composite parent) {
		super(parent, SWT.NONE);
		setLayout(new FillLayout(SWT.VERTICAL));
		List list = new List(this, SWT.BORDER | SWT.SINGLE);
		for (int i = 0; i < 10; i++) {
			list.add("item "+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 SWTSnippet16(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 *