本文整理匯總了Java中javafx.scene.control.MenuItem.setAccelerator方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.setAccelerator方法的具體用法?Java MenuItem.setAccelerator怎麽用?Java MenuItem.setAccelerator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setAccelerator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createMenuItem
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
public static MenuItem createMenuItem(String name, String commandName, String mnemonic) {
MenuItem menuItem = new MenuItem();
menuItem.setId(name + "MenuItem");
Node enabledIcon = getImageFrom(name, "icons/", FromOptions.NULL_IF_NOT_EXISTS);
if (enabledIcon != null) {
menuItem.setGraphic(enabledIcon);
}
menuItem.setText(commandName);
if (!"".equals(mnemonic)) {
menuItem.setAccelerator(KeyCombination.keyCombination(mnemonic));
}
return menuItem;
}
示例2: createCheckboxMenuItem
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
public static MenuItem createCheckboxMenuItem(String name, String commandName, String mnemonic) {
MenuItem menuItem = new CheckMenuItem();
menuItem.setId(name + "MenuItem");
Node enabledIcon = getImageFrom(name, "icons/", FromOptions.NULL_IF_NOT_EXISTS);
if (enabledIcon != null) {
menuItem.setGraphic(enabledIcon);
}
menuItem.setText(commandName);
if (!"".equals(mnemonic)) {
menuItem.setAccelerator(KeyCombination.keyCombination(mnemonic));
}
return menuItem;
}
示例3: createToolsMenu
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private Menu createToolsMenu()
{
Menu toolsMenu = new Menu("Tools");
MenuItem itemOptions = new MenuItem("Options");
itemOptions.setOnAction((e) -> controller.showOptionsMenu());
Menu modules = new Menu("Modules");
MenuItem itemModuleManager = new MenuItem("Module Manager...");
itemModuleManager.setOnAction((e) -> controller.showModuleManager());
MenuItem itemLoadJar = new MenuItem("Load Module JAR File...");
itemLoadJar.setOnAction((e) -> controller.loadModule());
MenuItem itemClearCache = new MenuItem("Clear Module Auto-Load Cache");
itemClearCache.setOnAction((e) -> controller.clearModuleCache());
MenuItem itemSerialTerminal = new MenuItem("Serial Terminal");
itemSerialTerminal.setAccelerator(new KeyCodeCombination(KeyCode.T,
KeyCombination.CONTROL_DOWN));
// TODO: set action
MenuItem itemNumConverter = new MenuItem("Number Converter");
itemNumConverter.setAccelerator(new KeyCodeCombination(KeyCode.F12));
itemNumConverter.setOnAction((e) -> controller.showNumberConverter());
modules.getItems().addAll(itemModuleManager, itemLoadJar, itemClearCache);
toolsMenu.getItems().addAll(itemOptions, modules, new SeparatorMenuItem(),
itemSerialTerminal, itemNumConverter);
return toolsMenu;
}
示例4: createHelpMenu
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private Menu createHelpMenu()
{
Menu helpMenu = new Menu("Help");
MenuItem itemQuickRef = new MenuItem("Quick Reference");
itemQuickRef.setAccelerator(new KeyCodeCombination(KeyCode.F1));
itemQuickRef.setOnAction((e) -> controller.showQuickReference());
MenuItem itemOnlineManual = new MenuItem("Online Manual");
itemOnlineManual.setOnAction((e) -> controller.showOnlineManual());
MenuItem itemReportIssue = new MenuItem("Report Issue (Requires Google Account");
itemReportIssue.setOnAction((e) -> controller.reportIssue());
MenuItem itemIssuesPage = new MenuItem("Open Issues Page");
itemIssuesPage.setOnAction((e) -> controller.showIssuesPage());
MenuItem itemAboutPLP = new MenuItem("About PLP Tool...");
itemAboutPLP.setOnAction((e) -> controller.showAboutPLPTool());
MenuItem itemSWLicense = new MenuItem("Third Party Software License");
itemSWLicense.setOnAction((e) -> controller.showThirdPartyLicenses());
helpMenu.getItems().addAll(itemQuickRef, itemOnlineManual,
new SeparatorMenuItem(), itemReportIssue, itemIssuesPage,
new SeparatorMenuItem(), itemAboutPLP, itemSWLicense);
return helpMenu;
}
示例5: createViewMenu
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private Menu createViewMenu()
{
Menu viewMenu = new Menu("View");
MenuItem itemClearOutput = new MenuItem("Clear Output Pane");
itemClearOutput.setAccelerator(new KeyCodeCombination(KeyCode.D,
KeyCombination.CONTROL_DOWN));
itemClearOutput.setOnAction((e) -> controller.clearConsole());
viewMenu.getItems().addAll(itemClearOutput);
return viewMenu;
}
示例6: createEditMenu
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private Menu createEditMenu()
{
Menu editMenu = new Menu("Edit");
MenuItem itemCopy = new MenuItem("Copy");
itemCopy.setAccelerator(new KeyCodeCombination(KeyCode.C,
KeyCombination.CONTROL_DOWN));
itemCopy.setOnAction((e) -> controller.editCopy());
MenuItem itemCut = new MenuItem("Cut");
itemCut.setAccelerator(new KeyCodeCombination(KeyCode.X,
KeyCombination.CONTROL_DOWN));
MenuItem itemPaste = new MenuItem("Paste");
itemPaste.setAccelerator(new KeyCodeCombination(KeyCode.V,
KeyCombination.CONTROL_DOWN));
MenuItem itemFandR = new MenuItem("Find and Replace");
itemFandR.setAccelerator(new KeyCodeCombination(KeyCode.F,
KeyCombination.CONTROL_DOWN));
MenuItem itemUndo = new MenuItem("Undo");
itemUndo.setAccelerator(new KeyCodeCombination(KeyCode.Z,
KeyCombination.CONTROL_DOWN));
itemUndo.setOnAction((e) -> controller.editUndo());
MenuItem itemRedo = new MenuItem("Redo");
itemRedo.setAccelerator(new KeyCodeCombination(KeyCode.Y,
KeyCombination.CONTROL_DOWN));
editMenu.getItems().addAll(itemCopy, itemCut, itemPaste, new SeparatorMenuItem(),
itemFandR, new SeparatorMenuItem(), itemUndo, itemRedo);
return editMenu;
}
示例7: createMenuBar
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private MenuBar createMenuBar(GoogleAutoRefreshThread autoRefreshThread) {
MenuItem logoutItem = new MenuItem("Logout");
logoutItem.setOnAction(evt -> logout());
MenuItem exitItem = new MenuItem("Exit");
exitItem.setAccelerator(KeyCombination.keyCombination("shortcut+q"));
exitItem.setOnAction(evt -> Platform.exit());
Menu fileMenu = new Menu("File");
fileMenu.getItems().add(logoutItem);
fileMenu.getItems().add(exitItem);
MenuItem refreshItem = new MenuItem("Refresh");
refreshItem.setOnAction(evt -> autoRefreshThread.restart());
refreshItem.setAccelerator(KeyCombination.keyCombination("F5"));
ToggleGroup intervalGroup = new ToggleGroup();
Menu autoRefreshItem = new Menu("Auto Refresh");
for (GoogleAutoRefreshThread.RefreshInterval interval : GoogleAutoRefreshThread.RefreshInterval.values()) {
RadioMenuItem intervalItem = new RadioMenuItem(interval.getName());
intervalItem.setOnAction(evt -> autoRefreshThread.setDelay(interval.getTime()));
intervalItem.setToggleGroup(intervalGroup);
intervalItem.setSelected(interval.getTime() == autoRefreshThread.getDelay());
autoRefreshItem.getItems().add(intervalItem);
}
Menu viewMenu = new Menu("View");
viewMenu.getItems().addAll(refreshItem, autoRefreshItem);
MenuBar menuBar = new MenuBar();
menuBar.setUseSystemMenuBar(true);
menuBar.getMenus().add(fileMenu);
menuBar.getMenus().add(viewMenu);
return menuBar;
}
示例8: MainMenuBar
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
public MainMenuBar(Stage mainStage) {
this.mainStage = mainStage;
fileChooser = new FileChooser();
Menu menuFile = new Menu("File");
this.getMenus().add(menuFile);
MenuItem menuItemNew = new MenuItem("New");
menuItemNew.setOnAction(e -> onNew());
menuItemNew.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN));
menuFile.getItems().add(menuItemNew);
MenuItem menuItemOpen = new MenuItem("Open...");
menuItemOpen.setOnAction(e -> onOpen());
menuItemOpen.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.CONTROL_DOWN));
menuFile.getItems().add(menuItemOpen);
MenuItem menuItemSave = new MenuItem("Save");
menuItemSave.setOnAction(e -> onSave());
menuItemSave.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN));
menuFile.getItems().add(menuItemSave);
MenuItem menuItemSaveAs = new MenuItem("Save As...");
menuItemSaveAs.setOnAction(e -> onSaveAs());
menuFile.getItems().add(menuItemSaveAs);
menuFile.getItems().add(new SeparatorMenuItem());
MenuItem menuItemExit = new MenuItem("Exit");
menuItemExit.setOnAction(e -> Platform.exit());
// menuItemExit.setAccelerator(new KeyCodeCombination(KeyCode.F4, KeyCombination.ALT_DOWN));
menuFile.getItems().add(menuItemExit);
Menu menuHelp = new Menu("Help");
this.getMenus().add(menuHelp);
MenuItem menuViewOnGithub = new MenuItem("View on GitHub");
menuViewOnGithub.setOnAction(e -> onViewGitHub());
menuHelp.getItems().add(menuViewOnGithub);
MenuItem menuItemAbout = new MenuItem("About Game Shelf");
menuItemAbout.setOnAction(e -> onAboutGameShelf());
menuHelp.getItems().add(menuItemAbout);
Menu menuDebug = new Menu("Debug");
this.getMenus().add(menuDebug);
MenuItem menuItemPrintGameList = new MenuItem("Print current game list");
menuItemPrintGameList.setOnAction(e -> onPrintCurrentGameList());
menuDebug.getItems().add(menuItemPrintGameList);
MenuItem menuItemOpenSystemList = new MenuItem("Import/Export system_list.csv");
menuItemOpenSystemList.setOnAction(e -> onImportExportSystemList());
menuDebug.getItems().add(menuItemOpenSystemList);
MenuItem menuItemTestImportSteamLibraryXML = new MenuItem("Test importing Steam library (.XML)");
menuItemTestImportSteamLibraryXML.setOnAction(e -> onTestImportSteamLibraryXML());
menuDebug.getItems().add(menuItemTestImportSteamLibraryXML);
}
示例9: parseSubMenus
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
protected void parseSubMenus (Menu menu, JsonArray jsonArray) {
for (int i = 0; i < jsonArray.size(); i++) {
//get json object
JsonObject entry = jsonArray.getJsonObject(i);
//get event and title
String event = entry.getString("event");
String title = entry.getString("title");
//create new menu item
MenuItem menuItem = new MenuItem(title);
//add click handler
menuItem.setOnAction(event1 -> {
System.out.println("open activitiy: " + event);
EventBus.getInstance().raiseEvent("open_activity", event);
});
menuItem.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN));
//check for shortcut
if (entry.containsKey("shortcut") && !entry.getString("shortcut").isEmpty()) {
String keys[] = entry.getString("shortcut").split("\\+");
if (keys.length > 1) {
KeyCombination.Modifier modifier = null;
if (keys[1].equals("SHIFT_DOWN")) {
modifier = KeyCombination.SHIFT_DOWN;
} else {
throw new UnsupportedOperationException("Unsupported key code: " + keys[1]);
}
//KeyCombination combination = KeyCombination.keyCombination(keys[1]);
menuItem.setAccelerator(new KeyCodeCombination(KeyCode.getKeyCode(keys[0]), modifier));
} else if (keys.length == 1) {
menuItem.setAccelerator(new KeyCodeCombination(KeyCode.getKeyCode(keys[0])));
} else {
//no shortcut is set
}
}
//add menu item to menu
menu.getItems().add(menuItem);
}
}
示例10: childMenuItem
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private MenuItem childMenuItem() {
MenuItem newChildItem = new MenuItem("New child task");
newChildItem.setAccelerator(FXKeyboard.buildKeyCombination(NEW_CHILD_KEY_SHORTCUT));
newChildItem.setOnAction(event -> shortcutAddChild());
return newChildItem;
}
示例11: siblingMenuItem
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private MenuItem siblingMenuItem() {
MenuItem newSiblingItem = new MenuItem("New sibling task");
newSiblingItem.setAccelerator(FXKeyboard.buildKeyCombination(NEW_SIBLING_KEY_SHORTCUT));
newSiblingItem.setOnAction(event -> shortcutAddSibling());
return newSiblingItem;
}
示例12: deleteMenuItem
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private MenuItem deleteMenuItem(TableRow<ObservableGanttTask> row) {
MenuItem removeItem = new MenuItem("Delete task");
removeItem.setAccelerator(FXKeyboard.buildKeyCombination(DELETE_KEY_SHORTCUT));
removeItem.setOnAction(event -> shortcutDelete(row.getIndex(), row.getItem()));
return removeItem;
}
示例13: createProjectMenu
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private Menu createProjectMenu()
{
Menu projectMenu = new Menu("Project");
MenuItem itemAssemble = new MenuItem("Assemble");
itemAssemble.setGraphic(new ImageView(new Image("toolbar_assemble.png")));
itemAssemble.setAccelerator(new KeyCodeCombination(KeyCode.F2));
itemAssemble.setOnAction((e) -> controller.assembleActiveProject());
MenuItem itemSimulate = new MenuItem("Simulate");
itemSimulate.setGraphic(new ImageView(new Image("toolbar_simulate.png")));
itemSimulate.setAccelerator(new KeyCodeCombination(KeyCode.F3));
itemSimulate.setOnAction((e) -> controller.simulateActiveProject());
MenuItem itemPLPBoard = new MenuItem("Program PLP Board...");
itemPLPBoard.setGraphic(new ImageView(new Image("toolbar_program.png")));
itemPLPBoard.setAccelerator(new KeyCodeCombination(KeyCode.F4,
KeyCombination.SHIFT_DOWN));
itemPLPBoard.setOnAction((e) -> controller.downloadActiveProjectToBoard());
MenuItem itemQuickProgram = new MenuItem("Quick Program");
itemQuickProgram.setAccelerator(new KeyCodeCombination(KeyCode.F4));
// TODO: itemQuickProgram.setOnAction(); {{what does this button do?}}
MenuItem itemNewASM = new MenuItem("New ASM File...");
itemNewASM.setOnAction((e) -> controller.createNewASM());
MenuItem itemImportASM = new MenuItem("Import ASM File...");
itemImportASM.setOnAction((e) -> controller.importASM());
MenuItem itemExportASM = new MenuItem("Export Selected ASM File...");
itemExportASM.setOnAction((e) -> controller.exportASM());
MenuItem itemRemoveASM = new MenuItem("Remove Selected ASM File from Project");
itemRemoveASM.setAccelerator(new KeyCodeCombination(KeyCode.E,
KeyCombination.CONTROL_DOWN));
itemRemoveASM.setOnAction((e) -> controller.removeASM());
MenuItem itemCurrentAsMain = new MenuItem("Set Current Open File as Main Program");
itemCurrentAsMain.setOnAction((e) -> controller.setMainASMFile());
projectMenu.getItems().addAll(itemAssemble, itemSimulate, itemPLPBoard,
itemQuickProgram, new SeparatorMenuItem(), itemNewASM, itemImportASM,
itemExportASM, itemRemoveASM, new SeparatorMenuItem(), itemCurrentAsMain);
return projectMenu;
}
示例14: createFileMenu
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
private Menu createFileMenu()
{
Menu fileMenu = new Menu("File");
MenuItem itemNew = new MenuItem("New PLP Project");
itemNew.setGraphic(new ImageView(new Image("menu_new.png")));
itemNew.setAccelerator(new KeyCodeCombination(KeyCode.N,
KeyCombination.CONTROL_DOWN));
itemNew.setOnAction((e) -> controller.createNewProject());
MenuItem itemNewASMFile = new MenuItem("New ASM File");
itemNewASMFile.setGraphic(new ImageView(new Image("menu_new.png")));
itemNewASMFile.setOnAction((e) -> controller.createNewASM());
MenuItem itemOpen = new MenuItem("Open Project");
itemOpen.setGraphic(new ImageView(new Image("toolbar_open.png")));
itemOpen.setAccelerator(new KeyCodeCombination(KeyCode.O,
KeyCombination.CONTROL_DOWN));
itemOpen.setOnAction((e) -> controller.openProject());
MenuItem itemSave = new MenuItem("Save");
itemSave.setGraphic(new ImageView(new Image("toolbar_save.png")));
itemSave.setAccelerator(new KeyCodeCombination(KeyCode.S,
KeyCombination.CONTROL_DOWN));
itemSave.setOnAction((e) -> controller.saveActiveProject());
MenuItem itemSaveAs = new MenuItem("Save As");
itemSaveAs.setOnAction((e) -> controller.saveActiveProjectAs());
MenuItem itemSaveAll = new MenuItem("Save All");
itemSaveAll.setAccelerator(new KeyCodeCombination(KeyCode.A,
KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
itemSaveAll.setOnAction((e) -> controller.saveAll());
MenuItem itemPrint = new MenuItem("Print");
itemPrint.setAccelerator(new KeyCodeCombination(KeyCode.P,
KeyCombination.CONTROL_DOWN));
itemPrint.setOnAction((e) -> controller.printActiveFile());
MenuItem itemExit = new MenuItem("Exit");
itemExit.setAccelerator(new KeyCodeCombination(KeyCode.Q,
KeyCombination.CONTROL_DOWN));
itemExit.setOnAction((e) -> controller.exit());
fileMenu.getItems().addAll(itemNew, itemNewASMFile, new SeparatorMenuItem(), itemOpen, itemSave,
itemSaveAs, new SeparatorMenuItem(), itemPrint, new SeparatorMenuItem(),
itemExit);
return fileMenu;
}
示例15: HelpMenuHandler
import javafx.scene.control.MenuItem; //導入方法依賴的package包/類
public HelpMenuHandler(String source){
viewHelp = new MenuItem(source);
viewHelp.setId("menu-item");
viewHelp.setAccelerator(new KeyCodeCombination(KeyCode.H, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN));
viewHelp.setOnAction(e -> handle());
}