/** * Adds a new {@link MenuItem} factory to the end of this handler. * * @param text the text to show * @param icon the icon to show * @param action the action to perform when the button is pressed * @return this instance */ default MenuBarTabHandler addMenuItem(String text, SpeedmentIcon icon, EventHandler<ActionEvent> action) { return set(text.replace("_", "").replace(" ", "-").toLowerCase(), () -> { final MenuItem item = new MenuItem(text); item.setGraphic(icon.view()); item.setOnAction(action); return item; }); }
public void setIcon(MenuItem menuItem, GlyphIcons icon, String fontSize, String iconSize) { if (menuItem == null) { throw new IllegalArgumentException("The menu item must not be 'null'!"); } Text label = createIcon(icon, iconSize); menuItem.setStyle("-fx-font-size: " + fontSize); menuItem.setGraphic(label); }
public void addIcon(MenuItem component, FontAwesome.Glyph icon) { if (icon != null) { component.setGraphic(getFontAwesome().create(icon).color(Color.BLACK)); } }
/** * Generates an hyperlink from a component * * @param controller * @param actionDefinition * @return Button */ public static MenuItem menuItemFrom(final AbstractViewController controller, final VLViewComponentXML actionDefinition) { final MenuItem menuItem = new MenuItem(); menuItem.setId(actionDefinition.getId()); final String title = actionDefinition.getPropertyValue(XMLConstants.LABEL); if (!StringUtils.isEmpty(title)) { menuItem.setText(controller.getLocalised(title)); } Label label = new Label(); IconUtils.setIcon(label, actionDefinition); menuItem.setGraphic(label); setOnAction(actionDefinition, menuItem, controller); return menuItem; } }
/** * Configures a {@link MenuItem} with the specified action. * * @param menuItem the menu item to configre * @param action the action * @param iconSize the icon size */ public static void configureMenuItem(MenuItem menuItem, FXAction action, int iconSize) { menuItem.setMnemonicParsing(true); menuItem.textProperty().bind(action.displayNameProperty()); menuItem.acceleratorProperty().bind(action.acceleratorProperty()); menuItem.setOnAction(action); menuItem.disableProperty().bind(action.enabledProperty().not()); if (action.getGraphicFactory() != null) { Node graphic = action.getGraphicFactory().createGraphic(iconSize); if (graphic != null) { menuItem.setGraphic(graphic); } } }