import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.*;

public class ImageMenuDemo {

	public static Display myDisplay;
	public static boolean internalCall = false;

	public static void main(String[] args) {
		internalCall = true;
		myDisplay = new Display();
		ImageMenuDemo imd = new ImageMenuDemo();
		imd.runDemo(myDisplay);
	}

	public void runDemo(Display display) {
		myDisplay = display;
		Shell shell = new Shell(display);
		shell.setSize(100,100);
		shell.setText("Image Menu Demo");
		shell.open();
		
		//load an image from a BMP file, to act
		//as the icon for our menu item
		//Image icon = new Image(display, "arrow.bmp");
		Image icon = new Image(display, "splash.jpg");

		//create a standard menu bar with a file menu 
		//and action option
		Menu bar = new Menu(shell, SWT.BAR);
		shell.setMenuBar(bar);
		MenuItem file = new MenuItem(bar, SWT.CASCADE);
		file.setText("File");
		Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
		MenuItem action = new MenuItem(fileMenu, SWT.PUSH);
		file.setMenu(fileMenu);
		action.setText("Action");

		//set the image for the Action MenuItem
		action.setImage(icon);

		while (!shell.isDisposed())
			if (!display.readAndDispatch())
				display.sleep();

		if (internalCall) display.dispose();
		icon.dispose();
	}

}
