本文整理匯總了Java中javafx.scene.control.CheckMenuItem.setAccelerator方法的典型用法代碼示例。如果您正苦於以下問題:Java CheckMenuItem.setAccelerator方法的具體用法?Java CheckMenuItem.setAccelerator怎麽用?Java CheckMenuItem.setAccelerator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.CheckMenuItem
的用法示例。
在下文中一共展示了CheckMenuItem.setAccelerator方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: MixedItemsMenu
import javafx.scene.control.CheckMenuItem; //導入方法依賴的package包/類
public MixedItemsMenu() {
super(MIXED_ID);
setId(MIXED_ID);
MenuItem graphics_menu_item = new MenuItem(MENU_ITEM_GRAPHICS_ID, new Rectangle(10, 10));
graphics_menu_item.setId(MENU_ITEM_GRAPHICS_ID);
graphics_menu_item.setAccelerator(MENU_ITEM_ACCELERATOR);
CheckMenuItem graphics_check_menu_item = new CheckMenuItem(CHECK_MENU_ITEM_GRAPHICS_ID, new Rectangle(10, 10));
graphics_check_menu_item.setId(CHECK_MENU_ITEM_GRAPHICS_ID);
graphics_check_menu_item.setAccelerator(CHECK_MENU_ITEM_ACCELERATOR);
RadioMenuItem graphics_radio_menu_item = new RadioMenuItem(RADIO_MENU_ITEM_GRAPHICS_ID, new Rectangle(10, 10));
graphics_radio_menu_item.setId(RADIO_MENU_ITEM_GRAPHICS_ID);
graphics_radio_menu_item.setAccelerator(RADIO_MENU_ITEM_ACCELERATOR);
HBox node_box_bool = new HBox();
node_box_bool.getChildren().addAll(new Rectangle(10, 10), new Label(NODE_MENU_ITEM_BOOL_ID));
CustomMenuItem graphics_node_menu_item = new CustomMenuItem(node_box_bool, true);
graphics_node_menu_item.setId(NODE_MENU_ITEM_BOOL_ID);
graphics_node_menu_item.setAccelerator(NODE_MENU_ITEM_ACCELERATOR);
SeparatorMenuItem separator_menu_item = new SeparatorMenuItem();
separator_menu_item.setId(SEPARATOR_MENU_ITEM_VOID_ID);
getItems().addAll(graphics_menu_item,
graphics_check_menu_item,
graphics_radio_menu_item,
graphics_node_menu_item,
separator_menu_item);
setEventHandlers();
}
示例2: viewMenu
import javafx.scene.control.CheckMenuItem; //導入方法依賴的package包/類
@MustCallOnJavaFXThread
private Menu viewMenu() {
Menu menu = new Menu( "_View" );
menu.setMnemonicParsing( true );
CheckMenuItem highlight = new CheckMenuItem( "_Highlight Options" );
highlight.setAccelerator( new KeyCodeCombination( KeyCode.H, KeyCombination.SHORTCUT_DOWN ) );
highlight.setMnemonicParsing( true );
bindMenuItemToDialog( highlight, () ->
showHighlightOptionsDialog( highlightOptions ) );
MenuItem orientation = new MenuItem( "Switch Pane Orientation" );
orientation.setAccelerator( new KeyCodeCombination( KeyCode.S,
KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN ) );
orientation.setOnAction( event -> logsPane.switchOrientation() );
CheckMenuItem font = new CheckMenuItem( "Fon_t" );
font.setAccelerator( new KeyCodeCombination( KeyCode.F,
KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN ) );
font.setMnemonicParsing( true );
bindMenuItemToDialog( font, () ->
showFontPicker( fontValue.getValue(), fontValue::setValue ) );
MenuItem showContextMenu = new MenuItem( "Show Context Menu" );
showContextMenu.setAccelerator( new KeyCodeCombination( KeyCode.E, KeyCombination.SHORTCUT_DOWN ) );
showContextMenu.setOnAction( event -> logsPane.showContextMenu() );
menu.getItems().addAll( highlight, orientation, font, showContextMenu );
return menu;
}
示例3: layoutMenu
import javafx.scene.control.CheckMenuItem; //導入方法依賴的package包/類
/**
* A separate helper function to generate the layouts menu. Used to dynamically refresh the loaded layouts
*
* @param menu
* The layout menu
*/
private void layoutMenu(Menu menu) {
menu.getItems().clear();
for (Layout l : wm.getLayouts()) {
String name = l.getName();
MenuItem item = new MenuItem(name.endsWith(".json") ? name.substring(0, name.length() - 5) : name);
item.setOnAction(e -> wm.getLayouts().setLayout(l));
menu.getItems().add(item);
}
// | | | -- Save Layout
MenuItem saveLayoutItem = new MenuItem("Save Current Layout");
saveLayoutItem.setOnAction(e -> {
File saveFile = UIUtils.saveFileSelector("Save layout", wm.getPrimaryStage(), "layouts", new ExtensionFilter("JSON Files *.json", "*.json"));
if (saveFile != null) {
if (!saveFile.getName().endsWith(".json"))
saveFile = new File(saveFile.getAbsolutePath() + ".json");
wm.getLayouts().saveLayout(saveFile);
wm.getLayouts().reload(false);
layoutMenu(menu);
}
});
// | | | -- Refresh Layouts
MenuItem reloadLayoutItem = new MenuItem("Refresh Layouts");
reloadLayoutItem.setOnAction(e -> {
wm.getLayouts().reload(false);
layoutMenu(menu);
});
// | | | -- Toggle Fullscreen
CheckMenuItem fullscreen = new CheckMenuItem("Fullscreen");
wm.getPrimaryStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
fullscreen.setAccelerator(new KeyCodeCombination(KeyCode.F11));
fullscreen.setSelected(wm.getPrimaryStage().isFullScreen());
fullscreen.setOnAction(e -> {
Stage wnd = wm.getPrimaryStage();
wnd.setFullScreen(!wnd.isFullScreen());
});
menu.getItems().addAll(new SeparatorMenuItem(), saveLayoutItem, reloadLayoutItem, fullscreen);
}
示例4: MainMenu
import javafx.scene.control.CheckMenuItem; //導入方法依賴的package包/類
public MainMenu(
final LibraryPane libraryPane,
final File dataDir,
final ResourceLocator loc,
final EditorCanvas canvas
) {
super();
final Menu menuFile = new Menu("File");
final MenuItem fileNew = new MenuItem("New");
fileNew.setAccelerator(KeyCombination.keyCombination("Ctrl+N"));
fileNew.setOnAction(event -> canvas.newStage(libraryPane, dataDir));
final MenuItem fileOpen = new MenuItem("Open");
fileOpen.setAccelerator(KeyCombination.keyCombination("Ctrl+O"));
fileOpen.setOnAction(event -> canvas.loadStage(
libraryPane, loc, dataDir));
final MenuItem fileSave = new MenuItem("Save");
fileSave.setAccelerator(KeyCombination.keyCombination("Ctrl+S"));
fileSave.setOnAction(event -> canvas.saveStage(dataDir));
fileSave.disableProperty().bind(canvas.saved);
final MenuItem fileSaveAs = new MenuItem("Save As...");
fileSaveAs.setAccelerator(KeyCombination.keyCombination("Shift+Ctrl+S"));
fileSaveAs.setOnAction(event -> canvas.saveStageAs(dataDir));
final MenuItem fileExit = new MenuItem("Exit");
fileExit.setAccelerator(KeyCombination.keyCombination("Ctrl+Q"));
fileExit.setOnAction(event -> {
if (canvas.promptSaveContinue(libraryPane, dataDir)) {
System.exit(0);
}
});
menuFile.getItems().addAll(
fileNew, fileOpen, fileSave, fileSaveAs, new SeparatorMenuItem(), fileExit);
final Menu menuWindow = new Menu("Window");
final CheckMenuItem showLibrary = new CheckMenuItem("Show library");
showLibrary.setSelected(true);
showLibrary.setAccelerator(KeyCombination.keyCombination("F2"));
libraryPane.visibleProperty().bind(showLibrary.selectedProperty());
menuWindow.getItems().add(showLibrary);
this.getMenus().addAll(menuFile, menuWindow);
}