Java by API/org.eclipse.swt.widgets/CoolBar

Материал из Java эксперт
Перейти к: навигация, поиск

new CoolBar(Composite parent, int style)

   <source lang="java">

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.ruputeSize(size.x, size.y));
   s.open();
   while (!s.isDisposed()) {
     if (!d.readAndDispatch())
       d.sleep();
   }
   d.dispose();
 }

}


      </source>