當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItem.setGraphic方法代碼示例

本文整理匯總了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);
}
 
開發者ID:Glavo,項目名稱:ClassViewer,代碼行數:19,代碼來源:TextPaneMenu.java

示例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);
}
 
開發者ID:Glavo,項目名稱:ClassViewer,代碼行數:19,代碼來源:AsciiPaneMenu.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:15,代碼來源:FXUIUtils.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:14,代碼來源:FXUIUtils.java

示例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);
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:9,代碼來源:TestRunner.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:14,代碼來源:TestRunner.java

示例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
    );
}
 
開發者ID:Glavo,項目名稱:ClassViewer,代碼行數:21,代碼來源:HexPaneMenu.java

示例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;
}
 
開發者ID:Glavo,項目名稱:ClassViewer,代碼行數:13,代碼來源:FileTreeNode.java

示例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;
}
 
開發者ID:AntonioGabrielAndrade,項目名稱:LIRE-Lab,代碼行數:10,代碼來源:CommandTriggerFactory.java

示例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;
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:14,代碼來源:Util.java

示例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;
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:47,代碼來源:PLPToolMenuBarPanel.java

示例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;
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:50,代碼來源:PLPToolMenuBarPanel.java

示例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;
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:7,代碼來源:EditorPaneController.java


注:本文中的javafx.scene.control.MenuItem.setGraphic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。