Dies ist eine alte Version des Dokuments!


Section mit Toolbar

Folgender Code ermöglicht es Buttons in eine Section einzubauen:

private void createSectionToolbar(Section section) {
   ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
   ToolBar toolbar = toolBarManager.createControl(section);
   final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
   toolbar.setCursor(handCursor);
   toolbar.addDisposeListener(new DisposeListener() {
      public void widgetDisposed(DisposeEvent e) {
         if ((handCursor != null) && (handCursor.isDisposed() == false)) {
            handCursor.dispose();
         }
      }
   });
 
   Action action1 = new Action("A1"){  // Hier wäre auch ein Action-Konstruktor mit Icon möglich
      public void run(){
         System.out.println("A1");
      }
   };
   toolBarManager.add(action1);
 
   Action action2 = new Action("A2"){  // Hier wäre auch ein Action-Konstruktor mit Icon möglich
      public void run(){
         System.out.println("A2");
      }
   };
   toolBarManager.add(action2);
 
   toolBarManager.update(true);
   section.setTextClient(toolbar);
}

Eigene Werkzeuge
Werkzeuge

gratis Counter by GOWEB
seit 9.10.2007