Java
Swt :: Toolbar
Introduction
Instanciation d'une toolbar
ToolBar bar = new ToolBar(s, SWT.HORIZONTAL); bar.setSize(300, 65); bar.setLocation(0,0);
Style Toolbar
  • SWT.FLAT : non-3D toolbar.
  • SWT.HORIZONTAL : Positions the toolbar at the top of the window, en dessous du menu.
  • SWT.WRAP : multiple lignes.
  • SWT.RIGHT : le texte apparait à la droite de l'image .
  • SWT.VERTICAL : Positionne la toobar de chaque côté de la fenetre dépendant de la méthode setLocation().
ToolItem
Pour créer chaque bouton, nous allons créer une instance de ToolItem.
ToolBar bar = new ToolBar(shell, SWT.HORIZONTAL); bar.setSize(300, 65); bar.setLocation(0,0);
ToolItem
  • SWT.PUSH : creer un toolbar Bouton cliquable.
  • SWT.CHECK : Créer un toogle Bouton( check).
  • SWT.RADIO : Créer un groupe de bouton radio.
  • SWT.SEPARATOR : ajoute un séparateur.
  • SWT.DROP_DOWN : ajoute un menu-liste.
ToolBar bar = new ToolBar(shell, SWT.HORIZONTAL); bar.setSize(300, 65); bar.setLocation(0,0); ToolItem textItem = new ToolItem(bar, SWT.PUSH); textItem.setText("Open Child"); //ajoute une image Image icon = new Image(d, "icons/Copy.ico"); textItem.setImage(icon); textItem.setText("Copy"); textItem.setToolTipText("Copy");
ToolItem Listener
Nous lions un listener sur le bouton
ToolItem textItem = new ToolItem(bar, SWT.PUSH); textItem.setText("Open Child"); //ajoute une image Image icon = new Image(d, "icons/Copy.ico"); textItem.setImage(icon); textItem.setText("Copy"); textItem.setToolTipText("Copy"); textItem.addSelectionListener(new SelectionListener( ) { public void widgetSelected(SelectionEvent e) { System.out.println("Copy"); } public void widgetDefaultSelected(SelectionEvent e) { } });
Imprimer
Notez cette page

S'il vous plait, prenez un moment pour remplir ce formulaire pour nous aider à mieux vous servir.

12345

    :: Ajouter aux favoris :: Contact