本文整理了Java中javafx.scene.control.MenuItem.setAccelerator()
方法的一些代码示例,展示了MenuItem.setAccelerator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setAccelerator()
方法的具体详情如下:
包路径:javafx.scene.control.MenuItem
类名称:MenuItem
方法名:setAccelerator
暂无
代码示例来源: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
private void initTopSectionContextMenu(ContextMenu contextMenu, boolean hasRanges) {
MenuItem setDestinationItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set destination"),
MaterialDesignIcon.AIRPLANE_LANDING);
setDestinationItem.setOnAction(e -> eventStudio().broadcast(
requestDestination(getSelectionModel().getSelectedItem().descriptor().getFile(), getOwnerModule()),
getOwnerModule()));
setDestinationItem.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.ALT_DOWN));
selectionChangedConsumer = e -> setDestinationItem.setDisable(!e.isSingleSelection());
contextMenu.getItems().add(setDestinationItem);
if (hasRanges) {
MenuItem setPageRangesItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set as range for all"),
MaterialDesignIcon.FORMAT_INDENT_INCREASE);
setPageRangesItem.setOnAction(e -> eventStudio().broadcast(
new SetPageRangesRequest(getSelectionModel().getSelectedItem().pageSelection.get()),
getOwnerModule()));
setPageRangesItem.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN));
selectionChangedConsumer = selectionChangedConsumer
.andThen(e -> setPageRangesItem.setDisable(!e.isSingleSelection()));
contextMenu.getItems().add(setPageRangesItem);
}
contextMenu.getItems().add(new SeparatorMenuItem());
}
代码示例来源:origin: stackoverflow.com
@FXML
MenuItem menuItem;
menuItem.setAccelerator(new KeyCodeCombination(KeyCode.M, KeyCombination.CONTROL_DOWN));
代码示例来源:origin: torakiki/pdfsam
MaterialDesignIcon.MINUS);
removeSelected.setOnAction(e -> eventStudio().broadcast(new RemoveSelectedEvent(), getOwnerModule()));
removeSelected.setAccelerator(new KeyCodeCombination(KeyCode.DELETE));
contextMenu.getItems().add(removeSelected);
selectionChangedConsumer = selectionChangedConsumer
moveBottomSelected.setAccelerator(new KeyCodeCombination(KeyCode.END, KeyCombination.ALT_DOWN));
moveDownSelected.setAccelerator(new KeyCodeCombination(KeyCode.DOWN, KeyCombination.ALT_DOWN));
moveUpSelected.setAccelerator(new KeyCodeCombination(KeyCode.UP, KeyCombination.ALT_DOWN));
moveTopSelected.setAccelerator(new KeyCodeCombination(KeyCode.HOME, KeyCombination.ALT_DOWN));
MaterialDesignIcon.CONTENT_DUPLICATE);
duplicateItem.setOnAction(e -> eventStudio().broadcast(new DuplicateSelectedEvent(), getOwnerModule()));
duplicateItem.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.ALT_DOWN));
代码示例来源:origin: torakiki/pdfsam
private void initBottomSectionContextMenu(ContextMenu contextMenu) {
MenuItem copyItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Copy to clipboard"),
MaterialDesignIcon.CONTENT_COPY);
copyItem.setOnAction(e -> copySelectedToClipboard());
MenuItem infoItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Document properties"),
MaterialDesignIcon.INFORMATION_OUTLINE);
infoItem.setOnAction(e -> Platform.runLater(() -> eventStudio()
.broadcast(new ShowPdfDescriptorRequest(getSelectionModel().getSelectedItem().descriptor()))));
MenuItem openFileItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open"),
MaterialDesignIcon.FILE_PDF_BOX);
openFileItem.setOnAction(e -> eventStudio()
.broadcast(new OpenFileRequest(getSelectionModel().getSelectedItem().descriptor().getFile())));
MenuItem openFolderItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open Folder"),
MaterialDesignIcon.FOLDER_OUTLINE);
openFolderItem.setOnAction(e -> eventStudio().broadcast(
new OpenFileRequest(getSelectionModel().getSelectedItem().descriptor().getFile().getParentFile())));
copyItem.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN));
infoItem.setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.ALT_DOWN));
openFileItem.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN));
openFolderItem.setAccelerator(
new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN, KeyCombination.ALT_DOWN));
contextMenu.getItems().addAll(new SeparatorMenuItem(), copyItem, infoItem, openFileItem, openFolderItem);
selectionChangedConsumer = selectionChangedConsumer.andThen(e -> {
copyItem.setDisable(e.isClearSelection());
infoItem.setDisable(!e.isSingleSelection());
openFileItem.setDisable(!e.isSingleSelection());
openFolderItem.setDisable(!e.isSingleSelection());
});
}
代码示例来源:origin: torakiki/pdfsam
private void initContextMenu() {
MenuItem infoItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Document properties"),
MaterialDesignIcon.INFORMATION_OUTLINE);
infoItem.setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.ALT_DOWN));
infoItem.setOnAction(
e -> Platform.runLater(() -> eventStudio().broadcast(new ShowPdfDescriptorRequest(descriptor))));
removeSelected = createMenuItem(DefaultI18nContext.getInstance().i18n("Remove"), MaterialDesignIcon.MINUS);
removeSelected.setOnAction(e -> eventStudio().broadcast(new ClearModuleEvent(), getOwnerModule()));
MenuItem setDestinationItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set destination"),
MaterialDesignIcon.AIRPLANE_LANDING);
setDestinationItem.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.ALT_DOWN));
setDestinationItem.setOnAction(e -> eventStudio()
.broadcast(requestDestination(descriptor.getFile(), getOwnerModule()), getOwnerModule()));
MenuItem openFileItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open"),
MaterialDesignIcon.FILE_PDF_BOX);
openFileItem.setOnAction(e -> eventStudio().broadcast(new OpenFileRequest(descriptor.getFile())));
MenuItem openFolderItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open Folder"),
MaterialDesignIcon.FOLDER_OUTLINE);
openFolderItem
.setOnAction(e -> eventStudio().broadcast(new OpenFileRequest(descriptor.getFile().getParentFile())));
field.getTextField().setContextMenu(new ContextMenu(setDestinationItem, new SeparatorMenuItem(), removeSelected,
new SeparatorMenuItem(), infoItem, openFileItem, openFolderItem));
}
代码示例来源:origin: torakiki/pdfsam
MenuItem copyItem = new MenuItem(i18n.i18n("Copy"));
copyItem.setId("copyLogMenuItem");
copyItem.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN));
copyItem.setOnAction(e -> copyLog(logView.getSelectionModel().getSelectedItems()));
代码示例来源:origin: com.powsybl/powsybl-gse-util
private MenuItem createDeleteNodeMenuItem(List<? extends TreeItem<N>> selectedTreeItems) {
MenuItem deleteMenuItem = new MenuItem(RESOURCE_BUNDLE.getString("Delete"), Glyph.createAwesomeFont('\uf1f8').size(ICON_SIZE));
if (selectedTreeItems.size() == 1) {
TreeItem<N> selectedTreeItem = selectedTreeItems.get(0);
N selectedTreeItemValue = selectedTreeItem.getValue();
if (selectedTreeItemValue instanceof Folder) {
Folder folder = (Folder) selectedTreeItemValue;
if (!folder.getChildren().isEmpty()) {
deleteMenuItem.setDisable(true);
}
} else if (selectedTreeItemValue instanceof Project) {
Project project = (Project) selectedTreeItemValue;
if (openedProjects.contains(project.getId())) {
deleteMenuItem.setDisable(true);
}
}
} else {
selectionContainsOpenedProjects(selectedTreeItems, deleteMenuItem);
}
deleteMenuItem.setOnAction(event -> createDeleteAlert(selectedTreeItems));
deleteMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.DELETE));
return deleteMenuItem;
}
代码示例来源:origin: io.github.factoryfx/javafxDataEditing
public void addMenu(Control tableView, Runnable copyTableCell, Supplier<String> createCsvFromTable){
MenuItem item = new MenuItem("Copy cell",uniformDesign.createIcon(FontAwesome.Glyph.COPY));
item.setOnAction(event -> {
copyTableCell.run();
});
item.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN));//don't work on ContextMenu but keep is for the display text
KeyCodeCombination keyCodeCombination = new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN);
tableView.addEventFilter(KeyEvent.KEY_RELEASED, event -> {
if (keyCodeCombination.match(event)) {
copyTableCell.run();
}
});
MenuItem export = new MenuItem("Copy table (csv)",uniformDesign.createIcon(FontAwesome.Glyph.TABLE));
export.setOnAction(event -> {
exportTableToClipboard(createCsvFromTable.get());
});
MenuItem fileExport = new MenuItem("Save table (csv)",uniformDesign.createIcon(FontAwesome.Glyph.FILE));
fileExport.setOnAction(event -> {
exportTableToFile(createCsvFromTable.get(),tableView.getScene().getWindow());
});
ContextMenu menu = new ContextMenu();
menu.getItems().add(item);
menu.getItems().add(export);
menu.getItems().add(fileExport);
tableView.setContextMenu(menu);
}
代码示例来源:origin: com.aquafx-project/aquafx
MenuItem menu12 = new MenuItem("_Open");
menu12.getStyleClass().add("OpenMenuItem");
menu12.setAccelerator(new KeyCharacterCombination("]",
KeyCombination.SHIFT_DOWN, KeyCombination.META_DOWN));
Menu menu13 = new Menu("_Submenu");
final MenuItem menu16 = new MenuItem(change[0]);
final boolean toggle = false;
menu16.setAccelerator(KeyCombination.keyCombination("Shortcut+C"));
menuItems.add(menu11);
menuItems.add(menu12);
代码示例来源:origin: org.copper-engine/copper-monitoring-client
copy.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN));
copy.setOnAction(new EventHandler<ActionEvent>() {
@Override
代码示例来源:origin: com.aquafx-project/aquafx
item2.getItems().addAll(item3, item4);
MenuItem item5 = new MenuItem("List Item 5");
item5.setAccelerator(KeyCombination.keyCombination("shortcut+H"));
MenuItem item6 = new MenuItem("List Item 6");
item6.setAccelerator(KeyCombination.keyCombination("Alt+shortcut+H"));
MenuItem item7 = new MenuItem("List Item 7");
item7.setDisable(true);
代码示例来源:origin: org.codehaus.griffon/griffon-javafx
runInsideUIThread(() -> control.setDisable(!action.getEnabled()));
action.acceleratorProperty().addListener((v, o, n) -> runInsideUIThread(() -> control.setAccelerator(n)));
runInsideUIThread(() -> control.setAccelerator(action.getAccelerator()));
代码示例来源:origin: com.aquafx-project/aquafx
menuServices.getItems().addAll(menuNoService, menuServPref);
MenuItem menuHide = new MenuItem("Sytemeinstellungen ausblenden");
menuHide.setAccelerator(KeyCombination.keyCombination("shortcut+H"));
MenuItem menuHideOthers = new MenuItem("Andere ausblenden");
menuHideOthers.setAccelerator(KeyCombination.keyCombination("Alt+shortcut+H"));
MenuItem menuShowAll = new MenuItem("Alle einblenden");
menuShowAll.setDisable(true);
windowClose.setAccelerator(KeyCombination.keyCombination("shortcut+W"));
MenuItem windowDock = new MenuItem("Im Dock ablegen");
windowDock.setAccelerator(KeyCombination.keyCombination("shortcut+M"));
CheckMenuItem actual = new CheckMenuItem("Datum & Uhrzeit");
actual.setSelected(true);
help.setAccelerator(KeyCombination.keyCombination("shortcut+?"));
menuHelp.getItems().addAll(new MenuItem("Schlie\u00dfen"), help);
代码示例来源:origin: com.aquafx-project/aquafx
menuServices.getItems().addAll(menuNoService, menuServPref);
MenuItem menuHide = new MenuItem("Sytemeinstellungen ausblenden");
menuHide.setAccelerator(KeyCombination.keyCombination("shortcut+H"));
MenuItem menuHideOthers = new MenuItem("Andere ausblenden");
menuHideOthers.setAccelerator(KeyCombination.keyCombination("Alt+shortcut+H"));
MenuItem menuShowAll = new MenuItem("Alle einblenden");
menuShowAll.setDisable(true);
windowClose.setAccelerator(KeyCombination.keyCombination("shortcut+W"));
MenuItem windowDock = new MenuItem("Im Dock ablegen");
windowDock.setAccelerator(KeyCombination.keyCombination("shortcut+M"));
CheckMenuItem actual = new CheckMenuItem("Datum & Uhrzeit");
actual.setSelected(true);
help.setAccelerator(KeyCombination.keyCombination("shortcut+?"));
menuHelp.getItems().addAll(new MenuItem("Schlie\u00dfen"), help);
代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine
minimizeMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.M, KeyCombination.SHORTCUT_DOWN));
minimizeMenuItem.setOnAction(e -> iconify());
closeMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN));
内容来源于网络,如有侵权,请联系作者删除!