new MenuItem(Menu optionsmenu, SWT.RADIO) : MenuItem « org.eclipse.swt.widgets « Java by API






new MenuItem(Menu optionsmenu, SWT.RADIO)


import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;

public class MainClass {

  public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);

    Menu m = new Menu(s, SWT.BAR);

    final MenuItem options = new MenuItem(m, SWT.CASCADE);
    options.setText("&Options");
    final Menu optionsmenu = new Menu(s, SWT.DROP_DOWN);
    options.setMenu(optionsmenu);
    final MenuItem checkItem = new MenuItem(optionsmenu, SWT.CHECK);
    checkItem.setText("&Checked Option");
    final MenuItem optionsseparator = new MenuItem(optionsmenu, SWT.SEPARATOR);
    final MenuItem radioItem1 = new MenuItem(optionsmenu, SWT.RADIO);
    radioItem1.setText("Radio &One");
    final MenuItem radioItem2 = new MenuItem(optionsmenu, SWT.RADIO);
    radioItem2.setText("Radio &Two");

    s.setMenuBar(m);

    s.open();
    while (!s.isDisposed()) {
      if (!d.readAndDispatch())
        d.sleep();
    }
    d.dispose();
  }
}

           
       








Related examples in the same category

1.new MenuItem(Menu menu, int style)
2.new MenuItem(Menu m, SWT.CASCADE)
3.new MenuItem(MenuItem filemenu, SWT.SEPARATOR)
4.MenuItem: addListener(int state, Listener lis)
5.MenuItem: addSelectionListener(SelectionListener lis)
6.MenuItem: setAccelerator(int key)
7.MenuItem: setMenu(Menu menu)
8.MenuItem: setText(String s)