Java Code Examples for javafx.scene.control.MenuItem#setMnemonicParsing()

The following examples show how to use javafx.scene.control.MenuItem#setMnemonicParsing() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogFX.java    From LogFX with GNU General Public License v3.0 6 votes vote down vote up
@MustCallOnJavaFXThread
private Menu fileMenu() {
    Menu menu = new Menu( "_File" );
    menu.setMnemonicParsing( true );

    MenuItem open = new MenuItem( "_Open File" );
    open.setAccelerator( new KeyCodeCombination( KeyCode.O, KeyCombination.SHORTCUT_DOWN ) );
    open.setMnemonicParsing( true );
    open.setOnAction( ( event ) -> new FileOpener( stage, this::open ) );

    MenuItem showLogFxLog = new MenuItem( "Open LogFX Log" );
    showLogFxLog.setAccelerator( new KeyCodeCombination( KeyCode.O,
            KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN ) );
    showLogFxLog.setOnAction( ( event ) ->
            open( LogFXLogFactory.INSTANCE.getLogFilePath().toFile() ) );

    MenuItem close = new MenuItem( "E_xit" );
    close.setAccelerator( new KeyCodeCombination( KeyCode.W,
            KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN ) );
    close.setMnemonicParsing( true );
    close.setOnAction( ( event ) -> stage.close() );
    menu.getItems().addAll( open, showLogFxLog, close );

    return menu;
}
 
Example 2
Source File: MyMenuBar.java    From classpy with MIT License 5 votes vote down vote up
private void createHelpMenu() {
    MenuItem aboutMenuItem = new MenuItem("_About");
    aboutMenuItem.setOnAction(e -> AboutDialog.showDialog());
    aboutMenuItem.setMnemonicParsing(true);

    Menu helpMenu = new Menu("_Help");
    helpMenu.getItems().add(aboutMenuItem);
    helpMenu.setMnemonicParsing(true);

    getMenus().add(helpMenu);
}