トップ 差分 一覧 ソース 検索 ヘルプ RSS ログイン

ToolBar

import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class ToolBarSample1 {
  public static void main (String [] args) {
    Display display = new Display ();
    Shell shell =new Shell(display);
    shell.setText("ToolBar Sample1");
    shell.setLayout(new FillLayout());
    
    ToolBar toolbar = new ToolBar(shell,SWT.NULL);
    
    ToolItem item1 = new ToolItem(toolbar,SWT.PUSH);
    item1.setText("Item1");
    
    ToolItem item2 = new ToolItem(toolbar,SWT.CHECK);
    item2.setText("Item2");
    
    // セパレータ
    ToolItem sep = new ToolItem(toolbar,SWT.SEPARATOR);
    
    ToolItem item3 = new ToolItem(toolbar,SWT.RADIO);
    item3.setText("Item3");
    
    shell.setSize(200,70);
    shell.open();
    
    while (!shell.isDisposed ()){
      if (!display.readAndDispatch ()){
        display.sleep ();
      }
    }
    display.dispose ();
  }
}

ToolBarのコンストラクタにオプションを与えることでフラットボタン(マウスを重ねたときだけボーダーが表示されるボタン)のツールバーを作成することもできます。

// フラットボタンのツールバーを作成
ToolBar toolbar = new ToolBar(shell,SWT.FLAT);

最終更新時間:2004年03月09日 03時46分16秒