List of usage examples for javafx.scene.control MenuItem setVisible
public final void setVisible(boolean value)
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Menus"); Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); MenuBar menuBar = new MenuBar(); Menu menu = new Menu("File"); MenuItem newItem = new MenuItem("New"); menu.getItems().add(newItem);/* w w w . jav a 2 s. c o m*/ menu.getItems().add(new MenuItem("Save")); menu.getItems().add(new SeparatorMenuItem()); menu.getItems().add(new MenuItem("Exit")); newItem.setVisible(false); menuBar.getMenus().add(menu); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); root.getChildren().add(menuBar); primaryStage.setScene(scene); primaryStage.show(); }