SWT CoolBar Test Demo : CoolBar « SWT JFace Eclipse « Java

SWT CoolBar Test Demo

SWT CoolBar Test Demo
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class SWTCoolBarTestDemo extends ApplicationWindow {
  public SWTCoolBarTestDemo() {

  protected Control createContents(Composite parent) {
    // --- Create the window title. ---

    getShell().setText("CoolBar Test");

    String asCoolItemSection[] = { "File", "Formatting", "Search" };
    CoolBar composite = new CoolBar(parent, SWT.NONE);
    for (int idxCoolItem = 0; idxCoolItem < 3; ++idxCoolItem) {
      CoolItem item = new CoolItem(composite, SWT.NONE);
      ToolBar tb = new ToolBar(composite, SWT.FLAT);
      for (int idxItem = 0; idxItem < 3; ++idxItem) {
        ToolItem ti = new ToolItem(tb, SWT.NONE);
            .setText(asCoolItemSection[idxCoolItem] + " Item #"
                + idxItem);
      Point p = tb.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      Point p2 = item.computeSize(p.x, p.y);
    return composite;

  public static void main(String[] args) {
    // --- Display SWTCoolBarTestDemo until the window is closed. ---

    SWTCoolBarTestDemo app = new SWTCoolBarTestDemo();


Related examples in the same category

1.CoolBar ExamplesCoolBar Examples
3.Coolbar Example 2
4.Coolbar Example
5.SWT ToolBar DemoSWT ToolBar Demo
6.SWY CoolBarClassSWY CoolBarClass
7.Drop-down a chevron menu containing hidden tool itemsDrop-down a chevron menu containing hidden tool items
8.Create a coolbar (relayout when resized)Create a coolbar (relayout when resized)
9.CoolBar example snippet: create a cool barCoolBar example snippet: create a cool bar
10.Control example snippet: print mouse state and button (down, move, up)Control example snippet: print mouse state and button (down, move, up)
11.Control example snippet: print key state, code and characterControl example snippet: print key state, code and character