Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can make MenuItem with styles SWT.CHECK, SWT.CASCADE, SWT.PUSH, SWT.RADIO, SWT.SEPARATOR <a href="http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/package-summary.html" rel="noreferrer">see javadoc</a>..</p> <p>So you can "hang" swt menu to selection of dropdown on toolbar item like this</p> <pre><code>public class Test { private Shell shell; public Test() { Display display = new Display(); shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new FillLayout(SWT.VERTICAL)); shell.setSize(50, 100); ToolBar toolbar = new ToolBar(shell, SWT.FLAT); ToolItem itemDrop = new ToolItem(toolbar, SWT.DROP_DOWN); itemDrop.setText("drop menu"); itemDrop.addSelectionListener(new SelectionAdapter() { Menu dropMenu = null; @Override public void widgetSelected(SelectionEvent e) { if(dropMenu == null) { dropMenu = new Menu(shell, SWT.POP_UP); shell.setMenu(dropMenu); MenuItem itemCheck = new MenuItem(dropMenu, SWT.CHECK); itemCheck.setText("checkbox"); MenuItem itemRadio = new MenuItem(dropMenu, SWT.RADIO); itemRadio.setText("radio1"); MenuItem itemRadio2 = new MenuItem(dropMenu, SWT.RADIO); itemRadio2.setText("radio2"); } if (e.detail == SWT.ARROW) { // Position the menu below and vertically aligned with the the drop down tool button. final ToolItem toolItem = (ToolItem) e.widget; final ToolBar toolBar = toolItem.getParent(); Point point = toolBar.toDisplay(new Point(e.x, e.y)); dropMenu.setLocation(point.x, point.y); dropMenu.setVisible(true); } } }); shell.open(); while(!shell.isDisposed()) { if(!display.readAndDispatch()) display.sleep(); } display.dispose(); } public static void main(String[] args) { new Test(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload