ToolItemCheckBox.java Source code

Java tutorial

Introduction

Here is the source code for ToolItemCheckBox.java

Source

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class ToolItemCheckBox {

    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        ToolBar bar = new ToolBar(shell, SWT.BORDER | SWT.VERTICAL);
        for (int i = 0; i < 4; i++) {
            ToolItem item = new ToolItem(bar, SWT.CHECK);
            item.setText("Item " + i);
        }
        bar.pack();

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