Example usage for javafx.scene.control MenuItem setMnemonicParsing

List of usage examples for javafx.scene.control MenuItem setMnemonicParsing

Introduction

In this page you can find the example usage for javafx.scene.control MenuItem setMnemonicParsing.

Prototype

public final void setMnemonicParsing(boolean value) 

Source Link

Usage

From source file:Main.java

@Override
public void start(final Stage primaryStage) {
    primaryStage.setTitle("title");
    Group root = new Group();
    Scene scene = new Scene(root, 400, 300, Color.WHITE);

    MenuBar menuBar = new MenuBar();
    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    Menu menu = new Menu("File");

    MenuItem exitItem = new MenuItem("Exit", null);
    exitItem.setMnemonicParsing(true);
    exitItem.setAccelerator(new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN));
    exitItem.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            Platform.exit();//  www  .j  av a 2s . c o  m
        }
    });
    menu.getItems().add(exitItem);

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

From source file:com.properned.application.SystemController.java

public void populateRecentFileMenu() {
    logger.info("Loading recent files");

    recentFileMenu.getItems().clear();//  w  w  w. j  a  va  2s  .co m
    List<RecentFile> recentFileList = Preferences.getInstance().getRecentFileList();
    for (final RecentFile recentFile : recentFileList) {
        if (recentFile.getFile().exists()) {
            MenuItem menuItemRecentFile = new MenuItem(recentFile.getFile().getAbsolutePath());
            menuItemRecentFile.setMnemonicParsing(false);
            menuItemRecentFile.setOnAction(new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    loadFileList(recentFile.getFile());
                }
            });
            recentFileMenu.getItems().add(menuItemRecentFile);
        }
    }
}