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

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

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

暂无

代码示例

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

/**
 * Adds a new {@link MenuItem} factory to the end of this handler.
 *
 * @param text    the text to show
 * @param action  the action to perform when the button is pressed
 * @return        this instance
 */
default MenuBarTabHandler addMenuItem(String text, EventHandler<ActionEvent> action) {
  return set(text.replace("_", "").replace(" ", "-").toLowerCase(), () -> {
    final MenuItem item = new MenuItem(text);
    item.setOnAction(action);
    return item;
  });
}

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

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

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

@Override
  void installMenuItems(ProjectTreeComponent projectTree) {
    projectTree.installContextMenu(SchemaProperty.class, (treeCell, node) -> {
      final MenuItem enableTables  = new MenuItem("Enable All Tables");
      final MenuItem disableTables = new MenuItem("Disable All Tables");

      enableTables.setOnAction(ev ->
        DocumentUtil.traverseOver(node)
          .filter(TableProperty.class::isInstance)
          .forEach(doc -> ((TableProperty) doc).enabledProperty().setValue(true))
      );

      disableTables.setOnAction(ev ->
        DocumentUtil.traverseOver(node)
          .filter(TableProperty.class::isInstance)
          .forEach(doc -> ((TableProperty) doc).enabledProperty().setValue(false))
      );

      return Stream.of(enableTables, disableTables);
    });
  }
}

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

@Override
  void installMenuItems(ProjectTreeComponent projectTree) {
    projectTree.installContextMenu(TableProperty.class, (treeCell, node) -> {
      final MenuItem enableColumns  = new MenuItem("Enable All Columns");
      final MenuItem disableColumns = new MenuItem("Disable All Columns");

      enableColumns.setOnAction(ev ->
        DocumentUtil.traverseOver(node)
          .filter(ColumnProperty.class::isInstance)
          .forEach(doc -> ((ColumnProperty) doc).enabledProperty().setValue(true))
      );

      disableColumns.setOnAction(ev ->
        DocumentUtil.traverseOver(node)
          .filter(ColumnProperty.class::isInstance)
          .forEach(doc -> ((ColumnProperty) doc).enabledProperty().setValue(false))
      );

      return Stream.of(enableColumns, disableColumns);
    });
  }
}

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

private <DOC extends DocumentProperty> Stream<MenuItem>
  installForDocumentType(TreeCell<DocumentProperty> treeCell, DOC node) {
    final MenuItem expandAll   = new MenuItem("Expand All", ProjectTreeIcon.BOOK_OPEN.view());
    final MenuItem collapseAll = new MenuItem("Collapse All", ProjectTreeIcon.BOOK.view());

    expandAll.setOnAction(ev ->
      DocumentUtil.traverseOver(node)
        .filter(HasExpandedProperty.class::isInstance)
        .forEach(doc -> ((HasExpandedProperty) doc).expandedProperty().setValue(true))
    );

    collapseAll.setOnAction(ev ->
      DocumentUtil.traverseOver(node)
        .filter(HasExpandedProperty.class::isInstance)
        .forEach(doc -> ((HasExpandedProperty) doc).expandedProperty().setValue(false))
    );

    return Stream.of(expandAll, collapseAll);
  }
}

代码示例来源: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: jfoenixadmin/JFoenix

MenuItem item1 = new MenuItem("Group");
item1.setOnAction((action) -> {
  ((JFXTreeTableView) getTreeTableView()).group(this);
});
MenuItem item2 = new MenuItem("UnGroup");
item2.setOnAction((action) -> {
  ((JFXTreeTableView) getTreeTableView()).unGroup(this);

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

MenuItem editItem = new MenuItem("Edit...");
editItem.setOnAction(e -> {
  PropertyDescriptorSpec spec = this.getSelectionModel().getSelectedItem();
MenuItem removeItem = new MenuItem("Remove");
removeItem.setOnAction(e -> {
  PropertyDescriptorSpec selected = this.getSelectionModel().getSelectedItem();
MenuItem addItem = new MenuItem("Add property...");
addItem.setOnAction(e -> onAddPropertyClicked());
MenuItem addItem2 = new MenuItem("Add property...");
addItem2.setOnAction(e -> onAddPropertyClicked());

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

final MenuItem item = new MenuItem("Enable editing");
final Tooltip tooltip = new Tooltip(tooltipText);

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

MenuItem item = new MenuItem("Generate from stack trace...");
item.setOnAction(e -> {
  try {

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

private MenuItem createMenuItem(String text, MaterialDesignIcon icon) {
  MenuItem item = new MenuItem(text);
  MaterialDesignIconFactory.get().setIcon(item, icon, "1.1em");
  item.setDisable(true);
  return item;
}

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

private MenuItem createMenuItem(String text, MaterialDesignIcon icon) {
  MenuItem item = new MenuItem(text);
  MaterialDesignIconFactory.get().setIcon(item, icon, "1.1em");
  item.setDisable(true);
  return item;
}

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

@Inject
  AppContextMenu(WorkspaceMenu workspace, ModulesMenu modulesMenu) {
    MenuItem exit = new MenuItem(DefaultI18nContext.getInstance().i18n("E_xit"));
    exit.setOnAction(e -> Platform.exit());
    exit.setAccelerator(new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN));
    getItems().addAll(workspace, modulesMenu);
    if (!Boolean.getBoolean(PreferencesDashboardItem.PDFSAM_DISABLE_SETTINGS_DEPRECATED)
        && !Boolean.getBoolean(PreferencesDashboardItem.PDFSAM_DISABLE_SETTINGS)) {
      MenuItem settings = new MenuItem(DefaultI18nContext.getInstance().i18n("_Settings"));
      settings.setOnAction(
          e -> eventStudio().broadcast(new SetActiveDashboardItemRequest(PreferencesDashboardItem.ID)));
      getItems().add(settings);
    }

    getItems().addAll(new SeparatorMenuItem(), exit);
  }
}

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

@Inject
  public ModulesMenu(List<Module> modules) {
    super(DefaultI18nContext.getInstance().i18n("_Modules"));
    setId("modulesMenu");
    Map<ModuleCategory, Menu> moduleSubmenus = new HashMap<>();
    for (final Module currentModule : modules) {
      ModuleCategory category = currentModule.descriptor().category;
      Menu currentMenu = moduleSubmenus.get(category);
      if (currentMenu == null) {
        currentMenu = new Menu(category.getDescription());
        moduleSubmenus.put(category, currentMenu);
      }
      MenuItem moduleMenu = new MenuItem(currentModule.descriptor().getName());
      moduleMenu.setOnAction(e -> eventStudio().broadcast(activeteModule(currentModule.id())));
      currentMenu.getItems().add(moduleMenu);
    }
    getItems().addAll(moduleSubmenus.values());
  }
}

代码示例来源: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: torakiki/pdfsam

@Inject
public WorkspaceMenu(RecentWorkspacesService service) {
  super(DefaultI18nContext.getInstance().i18n("_Workspace"));
  this.service = service;
  setId("workspaceMenu");
  MenuItem load = new MenuItem(DefaultI18nContext.getInstance().i18n("_Load"));
  load.setId("loadWorkspace");
  load.setOnAction(e -> loadWorkspace());
  MenuItem save = new MenuItem(DefaultI18nContext.getInstance().i18n("_Save"));
  save.setOnAction(e -> saveWorkspace());
  save.setId("saveWorkspace");
  recent = new Menu(DefaultI18nContext.getInstance().i18n("Recen_ts"));
  recent.setId("recentWorkspace");
  service.getRecentlyUsedWorkspaces().stream().map(WorkspaceMenuItem::new).forEach(recent.getItems()::add);
  MenuItem clear = new MenuItem(DefaultI18nContext.getInstance().i18n("_Clear recents"));
  clear.setOnAction(e -> clearWorkspaces());
  clear.setId("clearWorkspaces");
  getItems().addAll(load, save, new SeparatorMenuItem(), recent, clear);
  eventStudio().addAnnotatedListeners(this);
}

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

MenuItem copyItem = new MenuItem(i18n.i18n("Copy"));
copyItem.setId("copyLogMenuItem");
copyItem.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN));
MenuItem clearItem = new MenuItem(i18n.i18n("Clear"));
clearItem.setId("clearLogMenuItem");
clearItem.setOnAction(e -> logView.getItems().clear());
MenuItem selectAllItem = new MenuItem(i18n.i18n("Select all"));
selectAllItem.setId("selectAllLogMenuItem");
selectAllItem.setOnAction(e -> logView.getSelectionModel().selectAll());
MenuItem saveItem = new MenuItem(i18n.i18n("Save log"));
saveItem.setId("saveLogMenuItem");
saveItem.setOnAction(e -> saveLog());

代码示例来源: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: io.github.factoryfx/javafxDataEditing

private MenuItem menuItem(LanguageText text, CheckComboBox<T> comboBox, boolean value) {
  final MenuItem menuItem = new MenuItem(uniformDesign.getText(text));
  menuItem.setOnAction(event -> {
    comboBox.getItems().stream().map(comboBox::getItemBooleanProperty).forEach(s -> s.setValue(value));
    updateCheckComboBox(comboBox);
  });
  return menuItem;
}

代码示例来源:origin: com.powsybl/powsybl-gse-util

private MenuItem createCreateFolderMenuItem() {
  MenuItem menuItem = new MenuItem(RESOURCE_BUNDLE.getString("CreateFolder") + "...", Glyph.createAwesomeFont('\uf115').size(ICON_SIZE));
  menuItem.setOnAction(event ->
      treeModel.showCreateFolderDialog(window, selectedFolder.get()).ifPresent(newFolder -> {
        TreeItem<N> selectedItem = tree.getSelectionModel().getSelectedItem();
        refreshTreeItem(selectedItem);
      })
  );
  return menuItem;
}

相关文章