Class MenuPopupView

  • All Implemented Interfaces:
    Styleable, EventTarget

    public class MenuPopupView
    extends PopupView

    The MenuPopupView class is used to show JavaFX Menu instances within the user interface - it will appear relative to the given owner node.

    Example

    The following example shows a MenuPopupView when the user presses the button with the label "Click".

     public class MyApp extends MobileApplication {
       private Button buttonMenu;
    
      @Override
       public void init() {
         addViewFactory(HOME_VIEW, () -> {
           buttonMenu = new Button("Click");
           buttonMenu.setOnAction(e -> showLayer("New Layer"));
           return new View(buttonMenu) {
            @Override
             protected void updateAppBar(AppBar appBar) {
               appBar.setTitleText("MenuPopupView");
             }
           };
         });
         addLayerFactory("New Layer", () -> {
           Menu menu = new Menu();
           menu.getItems().addAll(new CheckMenuItem("Check Item 1"), new RadioMenuItem("Radio Item 1"), new MenuItem("Item 3"));
           return new MenuPopupView(buttonMenu, menu);
         });
       }
     }
     

    Screenshot of MenuPopupView

    Since:
    1.0.0
    • Constructor Detail

      • MenuPopupView

        public MenuPopupView​(Node ownerNode,
                             Menu menu)
        Creates a new MenuPopupView instance that will be displayed relative to the given ownerNode, and will contain the given Menu.
        Parameters:
        ownerNode - The node that the popup menu should be shown relative to.
        menu - The menu to show.