title: Limiting the number of visible rows in a menu: JavaFX
body: <p>Is there a way to limit the number of visible rows for a menu in JavaFX? </p>
  
  <p>Here is a working example</p>
  
  <pre><code>public class MenuProb extends Application {
  
      public void start(Stage primaryStage) {
          Group group = new Group();
          Scene scene = new Scene(group, 800, 600);
          MenuBar menuBar = new MenuBar();
          Menu someValues = new Menu("Values");
  
          for (int i = 0; i &lt; 50; i++) {
              MenuItem item = new MenuItem("Value " + i);
              someValues.getItems().add(item);
          }
  
          menuBar.getMenus().add(someValues);
          group.getChildren().addAll(menuBar);
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  }
  </code></pre>
  
  <p>When the above code is run, a menu is created wherein the scrollbar appears only after the menuitems have exceeded the screen height.</p>
  
  <p><a href="https://i.stack.imgur.com/AnnIs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AnnIs.png" alt="enter image description here"></a></p>
  
  <p>Is there a way to limit the number of visible rows to a pre-decided number? That is, a scrollbar appears if the number of rows exceeds that limit.  </p>