FileDocCategorySizeDatePackage
Ch08_01.javaAPI DocExample2584Thu Nov 20 15:01:20 GMT 2003org.eclipsebook.ch08

Ch08_01

public class Ch08_01 extends Object

Fields Summary
Display
display
Shell
shell
Menu
menuBar
Menu
fileMenu
Menu
helpMenu
MenuItem
fileMenuHeader
MenuItem
helpMenuHeader
MenuItem
fileExitItem
MenuItem
fileSaveItem
MenuItem
helpGetHelpItem
Label
label
Constructors Summary
public Ch08_01()

    
		display = new Display();
		shell = new Shell(display);
		shell.setText("Menu Example");
		shell.setSize(300, 200);
		
		label = new Label(shell, SWT.CENTER);
		label.setBounds(shell.getClientArea());

		menuBar = new Menu(shell, SWT.BAR);
		fileMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
		fileMenuHeader.setText("&File");
	
		fileMenu = new Menu(shell, SWT.DROP_DOWN);
		fileMenuHeader.setMenu(fileMenu);
	
		fileSaveItem = new MenuItem(fileMenu, SWT.PUSH);
		fileSaveItem.setText("&Save");
	
		fileExitItem = new MenuItem(fileMenu, SWT.PUSH);
		fileExitItem.setText("E&xit");
	
		helpMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
		helpMenuHeader.setText("&Help");
	
		helpMenu = new Menu(shell, SWT.DROP_DOWN);
		helpMenuHeader.setMenu(helpMenu);
	
		helpGetHelpItem = new MenuItem(helpMenu, SWT.PUSH);
		helpGetHelpItem.setText("&Get Help");
	
		fileExitItem.addSelectionListener(new fileExitItemListener());
		fileSaveItem.addSelectionListener(new fileSaveItemListener());
		helpGetHelpItem.addSelectionListener(new helpGetHelpItemListener());
	
		shell.setMenuBar(menuBar);
		shell.open();
		while(!shell.isDisposed()) {
			if(!display.readAndDispatch()) display.sleep();
		}
		display.dispose();
	
Methods Summary
public static voidmain(java.lang.String[] args)

        Ch08_01 menuExample = new Ch08_01();