CoolItem: setControl(Control con) : CoolItem « org.eclipse.swt.widgets « Java by API





CoolItem: setControl(Control con)

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class MainClass {

  public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);

    s.setText("A Tabbed Shell Example");
    final CoolBar bar = new CoolBar(s, SWT.BORDER);
    bar.setSize(280, 70);
    bar.setLocation(0, 0);
    // final Image openIcon = new Image(d, "c:\\icons\\open.jpg");

    final CoolItem openCoolItem = new CoolItem(bar, SWT.NONE);
    final Button openBtn = new Button(bar, SWT.PUSH);
    // openBtn.setImage(openIcon);
    openBtn.pack();
    Point size = openBtn.getSize();
    openCoolItem.setControl(openBtn);
    openCoolItem.setSize(openCoolItem.computeSize(size.x, size.y));

    s.open();
    while (!s.isDisposed()) {
      if (!d.readAndDispatch())
        d.sleep();
    }
    d.dispose();
  }
}


           
       










Related examples in the same category

1.new CoolItem(CoolBar bar, int style)
2.CoolItem: addSelectionListener(SelectionListener lis)
3.CoolItem: computeSize(int x, int y)