ToolBar: wrap on resize : ToolBar « SWT « Java Tutorial

ToolBar: wrap on resize
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * Contributors:
 *     IBM Corporation - initial API and implementation

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class ToolBarWrapResize {

  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    final ToolBar toolBar = new ToolBar(shell, SWT.WRAP);
    for (int i = 0; i < 12; i++) {
      ToolItem item = new ToolItem(toolBar, SWT.PUSH);
      item.setText("Item " + i);
    shell.addListener(SWT.Resize, new Listener() {
      public void handleEvent(Event e) {
        Rectangle rect = shell.getClientArea();
        Point size = toolBar.computeSize(rect.width, SWT.DEFAULT);
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())

17.64.1.ToolBar Constants
17.64.2.A toolbar can be horizontal or vertical.
17.64.3.Add Buttons to ToolBarAdd Buttons to ToolBar
17.64.4.Add ToolItem to ToolBarAdd ToolItem to ToolBar
17.64.5.ToolBar: create tool bar with normal, hot and disabled images.ToolBar: create tool bar with normal, hot and disabled images.
17.64.6.ToolBar: wrap on resizeToolBar: wrap on resize
17.64.7.Place a drop down menu in a tool barPlace a drop down menu in a tool bar
17.64.8.Add a combo box in a tool barAdd a combo box in a tool bar