List of usage examples for org.eclipse.swt.widgets Label setMenu
public void setMenu(Menu menu)
From source file:Menus.java
/** * Creates the No Radio Group pop-up menu * /* ww w .j a va2 s . c om*/ * @param shell the main window */ private void createNoRadioGroupPopUpMenu(Shell shell) { // Create a composite that the pop-up menu will be // associated with Label label = new Label(shell, SWT.BORDER); label.setText("No Radio Group Menu"); // Create the pop-up menu with the No Radio Group style Menu menu = new Menu(shell, SWT.POP_UP | SWT.NO_RADIO_GROUP); label.setMenu(menu); // Create all the items in the pop-up menu MenuItem item1 = new MenuItem(menu, SWT.RADIO); item1.setText("Radio One"); MenuItem item2 = new MenuItem(menu, SWT.RADIO); item2.setText("Radio Two"); MenuItem item3 = new MenuItem(menu, SWT.RADIO); item3.setText("Radio Three"); // Set the pop-up menu as the pop-up for the label label.setMenu(menu); }
From source file:Menus.java
/** * Creates the left-half pop-up menu/* w ww. ja v a 2 s .com*/ * * @param shell the main window */ private void createPopUpMenu(Shell shell) { // Create a composite that the pop-up menu will be // associated with Label label = new Label(shell, SWT.BORDER); label.setText("Pop-up Menu"); // Create the pop-up menu Menu menu = new Menu(label); // Create the images star = new Image(shell.getDisplay(), this.getClass().getResourceAsStream("java2s.gif")); circle = new Image(shell.getDisplay(), this.getClass().getResourceAsStream("java2s.gif")); square = new Image(shell.getDisplay(), this.getClass().getResourceAsStream("java2s.gif")); triangle = new Image(shell.getDisplay(), this.getClass().getResourceAsStream("java2s.gif")); // Create all the items in the pop-up menu MenuItem newItem = new MenuItem(menu, SWT.CASCADE); newItem.setText("New"); newItem.setImage(star); MenuItem refreshItem = new MenuItem(menu, SWT.NONE); refreshItem.setText("Refresh"); refreshItem.setImage(circle); MenuItem deleteItem = new MenuItem(menu, SWT.NONE); deleteItem.setText("Delete"); new MenuItem(menu, SWT.SEPARATOR); // Add a check menu item and select it MenuItem checkItem = new MenuItem(menu, SWT.CHECK); checkItem.setText("Check"); checkItem.setSelection(true); checkItem.setImage(square); // Add a push menu item MenuItem pushItem = new MenuItem(menu, SWT.PUSH); pushItem.setText("Push"); new MenuItem(menu, SWT.SEPARATOR); // Create some radio items MenuItem item1 = new MenuItem(menu, SWT.RADIO); item1.setText("Radio One"); item1.setImage(triangle); MenuItem item2 = new MenuItem(menu, SWT.RADIO); item2.setText("Radio Two"); MenuItem item3 = new MenuItem(menu, SWT.RADIO); item3.setText("Radio Three"); // Create a new radio group new MenuItem(menu, SWT.SEPARATOR); // Create some radio items MenuItem itema = new MenuItem(menu, SWT.RADIO); itema.setText("Radio A"); MenuItem itemb = new MenuItem(menu, SWT.RADIO); itemb.setText("Radio B"); MenuItem itemc = new MenuItem(menu, SWT.RADIO); itemc.setText("Radio C"); // Create the New item's dropdown menu Menu newMenu = new Menu(menu); newItem.setMenu(newMenu); // Create the items in the New dropdown menu MenuItem shortcutItem = new MenuItem(newMenu, SWT.NONE); shortcutItem.setText("Shortcut"); MenuItem iconItem = new MenuItem(newMenu, SWT.NONE); iconItem.setText("Icon"); // Set the pop-up menu as the pop-up for the label label.setMenu(menu); }