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

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

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

暂无

代码示例

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

copyItem.setId("copyLogMenuItem");
copyItem.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN));
copyItem.setOnAction(e -> copyLog(logView.getSelectionModel().getSelectedItems()));
clearItem.setId("clearLogMenuItem");
clearItem.setOnAction(e -> logView.getItems().clear());
selectAllItem.setId("selectAllLogMenuItem");
selectAllItem.setOnAction(e -> logView.getSelectionModel().selectAll());
saveItem.setId("saveLogMenuItem");
saveItem.setOnAction(e -> saveLog());

代码示例来源:origin: ssaring/sportstracker

private MenuItem createContextMenuItem(final String id, final String resourceKey, //
    final EventHandler<ActionEvent> handler) {
  final MenuItem menuItem = new MenuItem(getContext().getResources().getString(resourceKey));
  menuItem.setId(id);
  menuItem.setOnAction(handler);
  menuItem.getStyleClass().add("contextMenuItem");
  return menuItem;
}

代码示例来源:origin: com.bitplan.gui/com.bitplan.javafx

/**
 * create the Menu Bar
 * 
 * @param scene
 */
public MenuBar createMenuBar(Scene scene, App app) {
 MenuBar lMenuBar = new MenuBar();
 for (com.bitplan.gui.Menu amenu : app.getMainMenu().getSubMenus()) {
  Menu menu = new Menu(i18n(amenu.getId()));
  lMenuBar.getMenus().add(menu);
  for (com.bitplan.gui.MenuItem amenuitem : amenu.getMenuItems()) {
   MenuItem menuItem = new MenuItem(i18n(amenuitem.getId()));
   menuItem.setOnAction(this);
   menuItem.setId(amenuitem.getId());
   menu.getItems().add(menuItem);
  }
 }
 hideMenuButton = new Button("hide menu");
 hideMenuButton.setOnAction(new EventHandler<ActionEvent>() {
  @Override
  public void handle(ActionEvent e) {
   showMenuBar(scene, lMenuBar, !lMenuBar.isVisible());
  }
 });
 return lMenuBar;
}

代码示例来源: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;
 }
}

相关文章