クールバー・・・クールなバーのことなのでしょう。 SWTには、CoolBarクラスというものが用意されています。 これは、ToolBarとほとんど同じなのですが、サイズの調整をユーザーが行えるという機能を備えています。
ToolBarの場合は、ToolItemに直接SWT.PUSH等のスタイルを指定することで、ToolItemのスタイルを決めていましたが、 CoolBarの場合は、CoolItem#setControl(Control)メソッドで、CoolItemが扱うコントロールを指定します。 setControl(Control)メソッドで指定するコントロールは、CoolBarの子として作成されていなければなりません。
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.jface.window.Window;
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 CoolBarSample extends ApplicationWindow {
private CoolBarSample() {
super(null);
}
protected Control createContents(Composite parent) {
parent.getShell().setText("CoolBarサンプル");
/* CoolBarを配置するComposite */
Composite composite = new Composite(parent, SWT.NONE);
/* CoolBar作成 */
CoolBar coolBar = new CoolBar(composite, SWT.NONE);
/* ファイルカテゴリのバー領域作成 */
createCoolItem("file category ", coolBar);
/* エディットカテゴリのバー領域作成 */
createCoolItem("edit category ", coolBar);
coolBar.pack();
composite.pack();
parent.setSize(600, 200);
return parent;
}
/**
* parentの子としてCoolItemを作成する。
* 作成したCoolItemは、ToolBarを格納している。
* 格納しているToolBarの各ToolItemのテキストには、categoryの文字列が使用される。
* @param category
* ToolItemのそれぞれに使用される文字列
* @param parent
* CoolBar
*/
private void createCoolItem(String category, CoolBar parent) {
/* ToolBarをCoolBarの子としてつくり、ToolBarにToolItemを追加 */
ToolBar toolBar = new ToolBar(parent, SWT.NONE);
ToolItem toolItem1 = new ToolItem(toolBar, SWT.PUSH);
toolItem1.setText(category + "-first");
ToolItem toolItem2 = new ToolItem(toolBar, SWT.PUSH);
toolItem2.setText(category + "-second");
/* CoolItemをCoolBarの子として作成し、ToolBarをそのコントロールにセット */
CoolItem coolItem = new CoolItem(parent, SWT.NONE);
coolItem.setControl(toolBar);
/* coolItemのサイズ調整 */
// toolBarの適切サイズ取得
Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// toolBarの適切サイズに少しゆとりを持たせる
size.x += 20;
// coolItemのサイズ変更
coolItem.setSize(size);
}
public static void main(String[] args) {
Window w = new CoolBarSample();
w.setBlockOnOpen(true);
w.open();
Display.getCurrent().dispose();
}
}

これは、限られたスペースを有効利用するのに、とても便利な機能です。