Example usage for javafx.scene.control CustomMenuItem setHideOnClick

List of usage examples for javafx.scene.control CustomMenuItem setHideOnClick

Introduction

In this page you can find the example usage for javafx.scene.control CustomMenuItem setHideOnClick.

Prototype

public final void setHideOnClick(boolean value) 

Source Link

Usage

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");
    menu.getItems().add(new MenuItem("New"));
    menu.getItems().add(new MenuItem("Save"));
    menu.getItems().add(new SeparatorMenuItem());
    menu.getItems().add(new MenuItem("Exit"));

    CustomMenuItem customMenuItem = new CustomMenuItem(new Slider());
    customMenuItem.setHideOnClick(false);
    menu.getItems().add(customMenuItem);

    menuBar.getMenus().add(menu);//w  ww . j a v  a  2  s .  co m

    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    root.getChildren().add(menuBar);
    primaryStage.setScene(scene);
    primaryStage.show();
}