import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
public class ToolItemImage {
public static void main(String[] args) {
Display display = new Display();
Image image = new Image(display, "yourFile.gif");
Shell shell = new Shell(display);
ToolBar toolBar = new ToolBar(shell, SWT.FLAT | SWT.BORDER);
for (int i = 0; i < 12; i++) {
ToolItem item = new ToolItem(toolBar, SWT.DROP_DOWN);
item.setImage(image);
}
toolBar.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
image.dispose();
display.dispose();
}
}
|