1 | /*
|
---|
2 | * SWT009_08.java
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (c) 2002, 2007 EclipseOS2 Team.
|
---|
7 | * This file is made available under the terms of the Common Public License v1.0
|
---|
8 | * which accompanies this distribution, and is available at
|
---|
9 | * http://www.eclipse.org/legal/cpl-v10.html
|
---|
10 | */
|
---|
11 |
|
---|
12 | import org.eclipse.swt.widgets.Display;
|
---|
13 | import org.eclipse.swt.widgets.Shell;
|
---|
14 | import org.eclipse.swt.SWT;
|
---|
15 | import org.eclipse.swt.widgets.*;
|
---|
16 | import org.eclipse.swt.layout.FillLayout;
|
---|
17 | import org.eclipse.swt.graphics.*;
|
---|
18 |
|
---|
19 | public class SWT009_08 extends SWTTestCase {
|
---|
20 |
|
---|
21 | static {
|
---|
22 | STEP = "009";
|
---|
23 | TEST = "08";
|
---|
24 | DESC = "Menu";
|
---|
25 | }
|
---|
26 |
|
---|
27 | Shell createTopShell(Display display) {
|
---|
28 | return new Shell(display, SWT.SHELL_TRIM | SWT.NO_REDRAW_RESIZE);
|
---|
29 | }
|
---|
30 |
|
---|
31 |
|
---|
32 | void initComponents() {
|
---|
33 | shell.setText("Hello World Menu");
|
---|
34 | Menu bar = new Menu(shell, SWT.BAR);
|
---|
35 | shell.setMenuBar(bar);
|
---|
36 | MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
|
---|
37 | fileItem.setText("File");
|
---|
38 | Menu submenu = new Menu(shell, SWT.DROP_DOWN);
|
---|
39 | fileItem.setMenu(submenu);
|
---|
40 | MenuItem item = new MenuItem(submenu, SWT.PUSH);
|
---|
41 | item.addListener(SWT.Selection, new Listener() {
|
---|
42 | public void handleEvent(Event e) {
|
---|
43 | System.out.println("Select All");
|
---|
44 | }
|
---|
45 | });
|
---|
46 | item.setText("Select & All\tCtrl+A");
|
---|
47 | item.setAccelerator(SWT.CTRL + 'A');
|
---|
48 |
|
---|
49 | //POP-UP
|
---|
50 | Composite c1 = new Composite (shell, SWT.BORDER);
|
---|
51 | c1.setSize (300, 300);
|
---|
52 | Menu menu = new Menu (shell, SWT.POP_UP);
|
---|
53 | MenuItem itempu = new MenuItem (menu, SWT.PUSH);
|
---|
54 | itempu.setText ("Popup");
|
---|
55 | c1.setMenu (menu);
|
---|
56 | shell.setMenu (menu);
|
---|
57 |
|
---|
58 |
|
---|
59 | shell.setSize(300, 300);
|
---|
60 | shell.open();
|
---|
61 | //
|
---|
62 | // shell.pack();
|
---|
63 | // shell.open();
|
---|
64 |
|
---|
65 | }
|
---|
66 |
|
---|
67 |
|
---|
68 | void setTitle(String title) {
|
---|
69 | super.setTitle(title);
|
---|
70 | }
|
---|
71 |
|
---|
72 | public static void main(String[] args) {
|
---|
73 | go(new SWT009_08());
|
---|
74 | }
|
---|
75 |
|
---|
76 | }
|
---|