1 package org
.eclipse
.tracecompass
.internal
.provisional
.tmf
.ui
.views
.timegraph2
.swtjfx
.examples
;
3 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
4 import org
.eclipse
.swt
.SWT
;
5 import org
.eclipse
.swt
.events
.SelectionAdapter
;
6 import org
.eclipse
.swt
.events
.SelectionEvent
;
7 import org
.eclipse
.swt
.graphics
.Point
;
8 import org
.eclipse
.swt
.layout
.FillLayout
;
9 import org
.eclipse
.swt
.widgets
.Display
;
10 import org
.eclipse
.swt
.widgets
.Menu
;
11 import org
.eclipse
.swt
.widgets
.MenuItem
;
12 import org
.eclipse
.swt
.widgets
.Shell
;
13 import org
.eclipse
.swt
.widgets
.ToolBar
;
14 import org
.eclipse
.swt
.widgets
.ToolItem
;
17 public class SwtToobar2
{
22 Display display
= new Display();
23 shell
= new Shell(display
, SWT
.SHELL_TRIM
);
24 shell
.setLayout(new FillLayout(SWT
.VERTICAL
));
25 shell
.setSize(50, 100);
27 ToolBar toolbar
= new ToolBar(shell
, SWT
.FLAT
);
28 ToolItem itemDrop
= new ToolItem(toolbar
, SWT
.DROP_DOWN
);
29 itemDrop
.setText("drop menu");
31 itemDrop
.addSelectionListener(new SelectionAdapter() {
36 public void widgetSelected(SelectionEvent e
) {
37 if (dropMenu
== null) {
38 dropMenu
= new Menu(shell
, SWT
.POP_UP
);
39 shell
.setMenu(dropMenu
);
40 MenuItem itemCheck
= new MenuItem(dropMenu
, SWT
.CHECK
);
41 itemCheck
.setText("checkbox");
42 MenuItem itemRadio
= new MenuItem(dropMenu
, SWT
.RADIO
);
43 itemRadio
.setText("radio1");
44 MenuItem itemRadio2
= new MenuItem(dropMenu
, SWT
.RADIO
);
45 itemRadio2
.setText("radio2");
48 if (e
.detail
== SWT
.ARROW
) {
49 // Position the menu below and vertically aligned with the
50 // the drop down tool button.
51 final ToolItem toolItem
= (ToolItem
) e
.widget
;
52 final ToolBar toolBar
= toolItem
.getParent();
54 Point point
= toolBar
.toDisplay(new Point(e
.x
, e
.y
));
55 dropMenu
.setLocation(point
.x
, point
.y
);
56 dropMenu
.setVisible(true);
65 while (!shell
.isDisposed()) {
66 if (!display
.readAndDispatch()) {
74 public static void main(String
[] args
) {
This page took 0.032157 seconds and 5 git commands to generate.