Changeset 73 for trunk/tests


Ignore:
Timestamp:
May 23, 2008, 6:21:41 PM (17 years ago)
Author:
lpino
Message:
  • (SWT009_08.java) Completed the first basic menu test
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/SWT/java/SWT009_08.java

    r56 r73  
    44
    55/*
    6  * Copyright (c) 2002, 2005 EclipseOS2 Team.
     6 * Copyright (c) 2002, 2007 EclipseOS2 Team.
    77 * This file is made available under the terms of the Common Public License v1.0
    88 * which accompanies this distribution, and is available at
     
    3131
    3232        void initComponents() {
     33            shell.setText("Hello World Menu");
    3334            Menu bar = new Menu(shell, SWT.BAR);
    3435            shell.setMenuBar(bar);
     
    4445            });
    4546            item.setText("Select &All\tCtrl+A");
    46             item.setAccelerator(SWT.CTRL + 'A');
     47//            item.setAccelerator(SWT.CTRL + 'A');
     48            shell.addListener(SWT.MenuDetect, new Listener() {
     49              public void handleEvent(Event event) {
     50                Menu menu = new Menu(shell, SWT.POP_UP);
     51                MenuItem item = new MenuItem(menu, SWT.PUSH);
     52                item.setText("Menu Item");
     53                item.addListener(SWT.Selection, new Listener() {
     54                  public void handleEvent(Event e) {
     55                    System.out.println("Item Selected");
     56                  }
     57                });
     58                menu.setLocation(event.x, event.y);
     59                menu.setVisible(true);
     60                while (!menu.isDisposed() && menu.isVisible()) {
     61                  if (!display.readAndDispatch())
     62                    display.sleep();
     63                }
     64                menu.dispose();
     65              }
     66            });
    4767            shell.setSize(200, 200);
    4868            shell.open();
    49 
    50             shell.pack();
    51             shell.open();
     69//
     70//            shell.pack();
     71//            shell.open();
    5272               
    5373        }
Note: See TracChangeset for help on using the changeset viewer.