The Goal
          Keep walking……
          posts - 23,  comments - 1,  trackbacks - 0

          是JFace的類,繼承自ContributionManager,凡是繼承了IAction或IContribution接口的對象都可被加至ToolBarManager.你只要花時間為ToolBarManager添加Action,Toolbar和ToolItem實例會自動產生。

          你可通過調用ApplicationWindow的createToolBarManager()來為你的應用程序添加一個toolbar。與MenuManager不同的是,createToolBarManager()需要一個style參數,這個參數用來設定ToolBar所用的按鈕的風格:flat或normal。

          • ControlContribution

          除了MenuManager所用的ContributionItems之外,還有一個新的ContributionItem,只能被ToolBarManager使用——ControlContribution。這個類可將任何能被用于toolbar的Control打包進去。

          要使用ControlContribution類,必須要實現抽象方法createControl().

          toolBarManager.add(new ControlContribution("Custom") {
          protected Control createControl(Composite parent) {
          SashForm sf = new SashForm(parent, SWT.NONE);
          Button b1 = new Button(sf, SWT.PUSH);
          b1.setText("Hello");
          Button b2 = new Button(sf, SWT.PUSH);
          b2.setText("World");
          b2.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
          System.out.println("Selected:" + e);
          }
          });
          return sf;
          }
          });

          如果你希望有任何的事件發生,必須在你的controls上實現SelectionListeners

          • Creating toolbars by hand

          如果你不想ToolBarManager來創建toolbar的話,可以手動創建,需要用到ToolBar和ToolItem類.

          Toolbar
          是一個composite control,包含多個ToolItems.Toolbar由多個小圖標按鈕組成,一般是16-by-16bitmap圖片。每個按鈕都對應一個ToolItem。Toolbar可以是水平的也可以是垂直的,默認為水平

          ToolItem
          每一個ToolItem都有一個圖片,如果沒有,默認為紅色方塊。When the user selects a ToolItem from the menu, it broadcasts the event to any registered SelectionListeners.Your application should register a listener with each ToolItem and use that listener to perform whatever logic corresponds to the menu item.

          posted on 2006-04-07 16:32 JOO 閱讀(673) 評論(0)  編輯  收藏 所屬分類: SWT & JFace IN ACTION
          Hit the target!

          <2006年4月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          常用鏈接

          留言簿(2)

          隨筆分類(23)

          隨筆檔案(22)

          文章檔案(1)

          相冊

          Neighbor

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 肇源县| 阿荣旗| 正阳县| 奉节县| 察哈| 大英县| 崇义县| 苍溪县| 菏泽市| 云梦县| 平潭县| 辉县市| 遂川县| 比如县| 房产| 蒲城县| 新和县| 和田市| 纳雍县| 韶山市| 巴林右旗| 铁力市| 康马县| 淅川县| 和平区| 富平县| 三明市| 中宁县| 临邑县| 佛教| 全州县| 油尖旺区| 社旗县| 潼南县| 佛学| 深州市| 沂水县| 北流市| 石棉县| 广南县| 理塘县|