Example usage for javafx.scene.control MenuItem setText

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

Introduction

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

Prototype

public final void setText(String value) 

Source Link

Usage

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

@Override
public void initialize(URL location, ResourceBundle resources) {
    // Table Study
    initializeTable(tableStudy, StudyImpl.class);
    initializeTable(tablePlate, PlateImpl.class);
    initializeTable(tableSample, SampleImpl.class);
    initializeTable(tableInjection, InjectionImpl.class);
    initializeTable(tableCompound, CompoundImpl.class);
    initializeTable(tableHistory, OperationHistoryImpl.class);

    menuBar.setUseSystemMenuBar(true);//from   w w w  .ja  va 2 s  .c  o  m

    commandManager = new CommandManager();
    commandManager.setContext(commandManagerContext);
    final GUICommandPaneFactory commandPaneFactory = new GUICommandPaneFactory(commandManager);
    MetabolomeQC.addCorrectionCommands(commandManager);
    for (Map.Entry<String, Class> commend : commandManager.getCommands().entrySet()) {
        MenuItem menuItem = new MenuItem(commend.getKey());
        menuItem.setText(commend.getKey());
        menuItem.setOnAction(e -> {
            final Stage stage = new Stage();
            stage.initModality(Modality.WINDOW_MODAL);

            Parent guiCommand = commandPaneFactory.getCommandPane(commend.getKey(),
                    (commandEvent, managedCommand) -> {
                        stage.close();
                    });
            BorderPane margins = new BorderPane(guiCommand);
            BorderPane.setMargin(guiCommand, new Insets(10));

            stage.setScene(new Scene(margins));
            stage.initOwner(this.stage);
            stage.showAndWait();
            onRefresh(null);
        });
        correctionMenu.getItems().add(menuItem);
    }

    onRefresh(null);
}

From source file:net.sourceforge.pmd.util.fxdesigner.MainDesignerController.java

private void updateRecentFilesMenu() {
    List<MenuItem> items = new ArrayList<>();
    List<File> filesToClear = new ArrayList<>();

    for (final File f : recentFiles) {
        if (f.exists() && f.isFile()) {
            CustomMenuItem item = new CustomMenuItem(new Label(f.getName()));
            item.setOnAction(e -> loadSourceFromFile(f));
            item.setMnemonicParsing(false);
            Tooltip.install(item.getContent(), new Tooltip(f.getAbsolutePath()));
            items.add(item);//  w  w w. j a v  a  2s. com
        } else {
            filesToClear.add(f);
        }
    }
    recentFiles.removeAll(filesToClear);

    if (items.isEmpty()) {
        openRecentMenu.setDisable(true);
        return;
    }

    Collections.reverse(items);

    items.add(new SeparatorMenuItem());
    MenuItem clearItem = new MenuItem();
    clearItem.setText("Clear menu");
    clearItem.setOnAction(e -> {
        recentFiles.clear();
        openRecentMenu.setDisable(true);
    });
    items.add(clearItem);

    openRecentMenu.getItems().setAll(items);
}