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

The following examples show how to use javafx.scene.control.MenuItem#getText() . 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: CheckItemBuilt.java    From AsciidocFX with Apache License 2.0 6 votes vote down vote up
public static CheckItemBuilt check(String name, boolean checked) {
    RadioMenuItem item = new RadioMenuItem() {
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            MenuItem i = (MenuItem) o;

            return !(getText() != null ? !getText().equals(i.getText()) : i.getText() != null);

        }

        @Override
        public int hashCode() {
            return getText() != null ? getText().hashCode() : 0;
        }
    };
    item.setMnemonicParsing(false);
    item.setSelected(checked);
    item.setText(name);
    final CheckItemBuilt checkItemBuilt = new CheckItemBuilt(item);
    return checkItemBuilt;
}
 
Example 2
Source File: JavaFXElementPropertyAccessor.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public String getMenuItemText(Menu parentMenu, int index) {
    MenuItem menuItem = parentMenu.getItems().get(index);
    String text = menuItem.getText();
    if (text == null || "".equals(text)) {
        return getTextFromIcon(menuItem, index);
    }
    return text;
}
 
Example 3
Source File: JavaFXContextMenuElement.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public String getTextForMenuItem(MenuItem menuItem) {
    Menu parentMenu = menuItem.getParentMenu();
    if (parentMenu == null) {
        String text = menuItem.getText();
        if (text == null || "".equals(text)) {
            return getTextFromIcon(menuItem, -1);
        }
        return text;
    }
    return getTextForMenuItem(menuItem, parentMenu);
}
 
Example 4
Source File: RFXMenuItem.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public String getTextForMenuItem(MenuItem menuItem) {
    Menu parentMenu = menuItem.getParentMenu();
    if (parentMenu == null) {
        if (menuBar != null) {
            ObservableList<Menu> menus = menuBar.getMenus();
            return parentMenuText(menus, menus.indexOf(menuItem));
        }
        String text = menuItem.getText();
        if (text == null || "".equals(text)) {
            return getTextFromIcon(menuItem, -1);
        }
        return text;
    }
    return getTextForMenuItem(menuItem, parentMenu);
}
 
Example 5
Source File: IndexService.java    From xJavaFxTool-spring with Apache License 2.0 5 votes vote down vote up
public ContextMenu getSelectContextMenu(String selectText) {
    selectText = selectText.toLowerCase();
    ContextMenu contextMenu = new ContextMenu();
    for (MenuItem menuItem : indexController.getMenuItemMap().values()) {
        if (menuItem.getText().toLowerCase().contains(selectText)) {
            MenuItem menu_tab = new MenuItem(menuItem.getText(), menuItem.getGraphic());
            menu_tab.setOnAction(event1 -> {
                menuItem.fire();
            });
            contextMenu.getItems().add(menu_tab);
        }
    }
    return contextMenu;
}
 
Example 6
Source File: ModFuncContextMenu.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
private void onViewCode(ActionEvent ae) {
   MenuItem mi = (MenuItem) ae.getSource();
   String menuItemClicked = mi.getText();
   ModFunc mf = selectedItem.get();
   if(mf == null)
       return;
   String moduleName = mf.getModuleName();
   ErlyBerly.runIO(() -> {
       try{
            final String title;
            String modSrc;
            if(mf.isModule()) {
                modSrc = fetchModuleCode(menuItemClicked, moduleName);
                title = moduleName + " Source code";
            }
            else {
                String functionName = mf.getFuncName();
                Integer arity = mf.getArity();
                modSrc = fetchFunctionCode(menuItemClicked, moduleName, functionName, arity);
                title = moduleName;
            }
            Platform.runLater(() -> { showModuleSourceCode(title, modSrc); });
        }
        catch (Exception e) {
            throw new RuntimeException("failed to load the source code.", e);
        }
    });
}
 
Example 7
Source File: KeyCodeInfo.java    From CPUSim with GNU General Public License v3.0 4 votes vote down vote up
public void bindToMenuItem(MenuItem menuItem) {
    String menuText = menuItem.getText();
    menuItem.acceleratorProperty().bind(keycodeCombo);
}