本文整理汇总了Java中javafx.scene.control.MenuItem.setGraphic方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setGraphic方法的具体用法?Java MenuItem.setGraphic怎么用?Java MenuItem.setGraphic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setGraphic方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TextPaneMenu
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public TextPaneMenu(TextArea textArea) {
this.textArea = textArea;
MenuItem copy = new MenuItem("_Copy");
this.setStyle(FontUtils.setUIFont(this.getStyle()));
copy.setMnemonicParsing(true);
copy.setOnAction(e -> {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection s = new StringSelection(
textArea.getSelectedText()
);
clipboard.setContents(s, null);
});
copy.setGraphic(new ImageView(ImageUtils.copyImage));
getItems().addAll(copy);
}
示例2: AsciiPaneMenu
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public AsciiPaneMenu(TextArea textArea) {
this.textArea = textArea;
MenuItem copy = new MenuItem("_Copy");
this.setStyle(FontUtils.setUIFont(this.getStyle()));
copy.setMnemonicParsing(true);
copy.setOnAction(e -> {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection s = new StringSelection(
textArea.getSelectedText().replace("\n", "")
);
clipboard.setContents(s, null);
});
copy.setGraphic(new ImageView(ImageUtils.copyImage));
getItems().addAll(copy);
}
示例3: 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;
}
示例4: 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;
}
示例5: populateSavedHistory
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private void populateSavedHistory(JSONArray savedHistory) {
for (int i = 0; i < savedHistory.length(); i++) {
JSONObject test = savedHistory.getJSONObject(i);
MenuItem item = createMenuItem(test, true);
item.setGraphic(FXUIUtils.getIcon("favourite"));
historyMenuItems.add(item);
}
}
示例6: populateUnSavedHistory
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private void populateUnSavedHistory(JSONArray unsavedHistory) {
if (unsavedHistory.length() > 0 && historyMenuItems.size() > 0) {
historyMenuItems.add(new SeparatorMenuItem());
}
ArrayList<MenuItem> items = new ArrayList<>();
for (int i = 0; i < unsavedHistory.length(); i++) {
JSONObject testJSON = unsavedHistory.getJSONObject(i);
MenuItem item = createMenuItem(testJSON, false);
item.setGraphic(getIcon(State.valueOf(testJSON.getString("state"))));
items.add(0, item);
}
historyMenuItems.addAll(items);
}
示例7: HexPaneMenu
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public HexPaneMenu(TextArea textArea) {
MenuItem copy = new MenuItem("_Copy");
this.setStyle(FontUtils.setUIFont(this.getStyle()));
copy.setMnemonicParsing(true);
copy.setOnAction(e -> {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection s = new StringSelection(
textArea.getSelectedText().replace("\n", "")
);
clipboard.setContents(s, null);
});
copy.setGraphic(new ImageView(ImageUtils.copyImage));
getItems().addAll(
copy
);
}
示例8: copyPathMenu
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public MenuItem copyPathMenu() {
MenuItem menu = new MenuItem("Copy path");
menu.setStyle(FontUtils.setUIFont(menu.getStyle()));
menu.setGraphic(new ImageView(ImageUtils.copyImage));
menu.setOnAction(event -> {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection selection = new StringSelection(url.toString());
clipboard.setContents(selection, null);
});
return menu;
}
示例9: createMenuItem
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public MenuItem createMenuItem(Command<E> command, CommandArgProvider<E> argProvider) {
MenuItem item = new MenuItem(command.getLabel());
item.setGraphic(command.getIcon());
item.setOnAction(event -> command.execute(argProvider.provide()));
item.setId(command.getNodeId());
return item;
}
示例10: getSimpleMenuItem
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public static MenuItem getSimpleMenuItem(String text, Node graphic, Consumer<ActionEvent> eventHandler) {
MenuItem item = new MenuItem();
if (text != null) {
item.setText(text);
}
if (graphic != null) {
item.setGraphic(graphic);
}
if (eventHandler != null) {
item.setOnAction(eventHandler::accept);
}
return item;
}
示例11: 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;
}
示例12: 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;
}
示例13: createMenuItem
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private MenuItem createMenuItem(String name, Runnable action,
FontAwesomeIcon icon) {
MenuItem item = createMenuItem(name, action);
item.setGraphic(GlyphsDude.createIcon(icon));
return item;
}