javafx.scene.control.MenuItem.setText()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中javafx.scene.control.MenuItem.setText()方法的一些代码示例,展示了MenuItem.setText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setText()方法的具体详情如下:
包路径:javafx.scene.control.MenuItem
类名称:MenuItem
方法名:setText

暂无

代码示例

代码示例来源:origin: pmd/pmd

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);
    } 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);
}

代码示例来源:origin: torakiki/pdfsam

public ClearButton(String ownerModule) {
  this.ownerModule = defaultString(ownerModule);
  getStyleClass().addAll(Style.BUTTON.css());
  getStyleClass().add("pdfsam-split-button");
  setTooltip(new Tooltip(DefaultI18nContext.getInstance().i18n("Removes every document")));
  setText(DefaultI18nContext.getInstance().i18n("_Clear"));
  setOnAction(this::clear);
  MenuItem clearAllSettings = new MenuItem();
  clearAllSettings.setText(DefaultI18nContext.getInstance().i18n("C_lear all settings"));
  clearAllSettings.setOnAction(this::clearAll);
  getItems().add(clearAllSettings);
}

代码示例来源:origin: org.copper-engine/copper-monitoring-client

public MenuItem createShowFormMenuItem() {
  MenuItem menuItem = new MenuItem();
  menuItem.setText(title);
  menuItem.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent event) {
      createForm().show();
    }
  });
  menuItem.setDisable(!enabled);
  return menuItem;
}

代码示例来源:origin: org.codehaus.griffon/griffon-javafx

private static void updateLabeled(@Nonnull final MenuItem node, @Nonnull final GriffonApplication application) {
  runInsideUIThread(() -> {
    String key = getI18nKey(node);
    String args = getI18nArgs(node);
    String defaultValue = getI18nDefaultValue(node);
    Object[] argArray = isBlank(args) ? EMPTY_OBJECT_ARRAY : args.split(",");
    if (isBlank(defaultValue)) {
      node.setText(application.getMessageSource().getMessage(key, argArray, application.getLocale()));
    } else {
      node.setText(application.getMessageSource().getMessage(key, argArray, application.getLocale(), defaultValue));
    }
  });
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

/**
  * 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;
 }
}

代码示例来源:origin: org.codehaus.griffon/griffon-javafx

control.setOnAction(action.getOnAction());
action.nameProperty().addListener((v, o, n) -> runInsideUIThread(() -> control.setText(n)));
runInsideUIThread(() -> control.setText(action.getName()));

代码示例来源:origin: com.intuit.karate/karate-core

calledMenuItem.setOnAction(e -> {
  showCalled = !showCalled;
  calledMenuItem.setText(getCalledMenuText());
  runButton.setText(getRunButtonText());
});

相关文章