当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem.setId方法代码示例

本文整理汇总了Java中javafx.scene.control.MenuItem.setId方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setId方法的具体用法?Java MenuItem.setId怎么用?Java MenuItem.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.MenuItem的用法示例。


在下文中一共展示了MenuItem.setId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildMenuItem

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private void buildMenuItem() {
    for (int i = 0; i < this.batpack.getModuleCount(); i++) {
        Group module = batteryModules.get(i);
        String labelText = ((Label) module.getChildren().get(3)).getText();
        MenuItem menuItem = new MenuItem(labelText);
        menuItem.setId(Integer.toString(i));
        EventHandler<ActionEvent> updateCells;
        updateCells = (event) -> {
            MenuItem menu = (MenuItem) event.getSource();
            int id = Integer.parseInt(menu.getId());
            moduleChooser.setText("module " + (id + 1));
            updateCells(id);
        };
        menuItem.setOnAction(updateCells);
        List<MenuItem> menuItems = new ArrayList<>();
        menuItems.add(menuItem);
        moduleChooser.getItems().addAll(menuItems);
    }
}
 
开发者ID:de-sach,项目名称:BatpackJava,代码行数:20,代码来源:batteryMonitorLayoutController.java

示例2: createMenuBar

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
/**
 * create the Menu Bar
 * 
 * @param scene
 */
public MenuBar createMenuBar(Scene scene, com.bitplan.gui.App app) {
  MenuBar lMenuBar = new MenuBar();
  for (com.bitplan.gui.Menu amenu : app.getMainMenu().getSubMenus()) {
    Menu menu = new Menu(i18n(amenu.getId()));
    lMenuBar.getMenus().add(menu);
    for (com.bitplan.gui.MenuItem amenuitem : amenu.getMenuItems()) {
      MenuItem menuItem = new MenuItem(i18n(amenuitem.getId()));
      menuItem.setOnAction(this);
      menuItem.setId(amenuitem.getId());
      menu.getItems().add(menuItem);
    }
  }

  hideMenuButton = new Button(I18n.get(I18n.HIDE_MENU));
  hideMenuButton.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent e) {
      showMenuBar(scene, lMenuBar, !lMenuBar.isVisible());
    }
  });
  return lMenuBar;
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:28,代码来源:JavaFXDisplay.java

示例3: initTableContextMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private void initTableContextMenu() {
      TextField textField = new TextField("Type Something"); // we will add a popup menu to this text field
      contextMenu = new ContextMenu();

      MenuItem pauseP = new MenuItem("Stop process");
pauseP.setId("pausep");
		
MenuItem continueP = new MenuItem("Continue process");
continueP.setId("continuep");
		
MenuItem killP = new MenuItem("Kill process");
killP.setId("killp");
      
pauseP.setOnAction(actionEventHandler);
continueP.setOnAction(actionEventHandler);
killP.setOnAction(actionEventHandler);


      contextMenu.getItems().addAll(pauseP, continueP, new SeparatorMenuItem(), killP);
      // ...
      textField.setContextMenu(contextMenu);
  }
 
开发者ID:dhiogoboza,项目名称:SystemMonitorJFX,代码行数:23,代码来源:MainStage.java

示例4: 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

示例5: 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

示例6: getContextMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public static List<MenuItem> getContextMenu(final Tab tab, final int posTab)
{
    final MenuItem close = new MenuItemTranslate("menu.tab.item.close");
    final MenuItem closeOther = new MenuItemTranslate("menu.tab.item.closeOther");
    final MenuItem closeLeft = new MenuItemTranslate("menu.tab.item.closeLeft");
    final MenuItem closeRight = new MenuItemTranslate("menu.tab.item.closeRight");
    final MenuItem closeAll = new MenuItemTranslate("menu.tab.item.closeAll");

    close.setId("close");
    closeOther.setId("close_other");
    closeLeft.setId("close_left");
    closeRight.setId("close_right");
    closeAll.setId("close_all");

    final ArrayList<MenuItem> item = new ArrayList<>();

    item.add(close);

    if (tab.getTabPane().getTabs().size() > 1)
    {
        item.add(closeOther);

        if (posTab != 0)
            item.add(closeLeft);
        if (posTab != tab.getTabPane().getTabs().size() - 1)
            item.add(closeRight);

        item.add(new SeparatorMenuItem());
        item.add(closeAll);
    }

    return item;
}
 
开发者ID:Leviathan-Studio,项目名称:MineIDE,代码行数:34,代码来源:TabHelper.java

示例7: 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

示例8: setupFileMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private void setupFileMenu() {
    List<Command<Void>> commands = applicationCommands.getFileMenuCommands();
    for (Command<Void> command : commands) {
        MenuItem menuItem = commandTriggerFactory.createMenuItem(command, () -> null);
        menuItem.setId(command.getNodeId());
        fileMenu.getItems().add(menuItem);
    }
}
 
开发者ID:AntonioGabrielAndrade,项目名称:LIRE-Lab,代码行数:9,代码来源:MenuBarController.java

示例9: setupHelpMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private void setupHelpMenu() {
    List<Command<Void>> commands = applicationCommands.getHelpMenuCommands();
    for (Command<Void> command : commands) {
        MenuItem menuItem = commandTriggerFactory.createMenuItem(command, () -> null);
        menuItem.setId(command.getNodeId());
        helpMenu.getItems().add(menuItem);
    }
}
 
开发者ID:AntonioGabrielAndrade,项目名称:LIRE-Lab,代码行数:9,代码来源:MenuBarController.java

示例10: getMenuItem

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private MenuItem getMenuItem(String name, String id) {
    MenuItem menuItem = new MenuItem(name);
    menuItem.setId(id);
    menuItem.setOnAction(event -> {
        MenuItem item = (MenuItem) event.getSource();
        BucketFile bucketFile = tableView.getSelectionModel().getSelectedItem();
        if (bucketFile != null) {
            handleAction(item.getId(), bucketFile);
        }
    });
    return menuItem;
}
 
开发者ID:cmlanche,项目名称:javafx-qiniu-tinypng-client,代码行数:13,代码来源:ContentView.java

示例11: 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());
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:7,代码来源:HelpMenuHandler.java

示例12: createApplicationLevelMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
/**
 * Create Technical Analysis Tool Application Level MenuBar
 * @return MenuBar that is used for application menu
 */
public MenuBar createApplicationLevelMenu(TatMain app, Stage primaryStage, FinancialMarket fm, TatConfig config){
    application = app;
    MenuBar menuBar = new MenuBar();
    /**
     * Create File Menu
     */
    Menu fileMenu = new Menu("File");
    this.primaryStage = primaryStage;
    //Create data import menu item suit
    MenuItem itemLoadMarketData = new MenuItem("Market data import...", new ImageView( new Image("icon/IMPORT_MARKET_DATA.png")));
    itemLoadMarketData.setAccelerator(KeyCombination.keyCombination("Ctrl + I"));
    itemLoadMarketData.setId("menuText");
    EventHandler<ActionEvent> actionImportMarketData = onDataImportAction(fm, config);
    itemLoadMarketData.setOnAction(actionImportMarketData);
    
    //Create file read menu item suit
    MenuItem itemUpdateMarketData = new MenuItem("Market data update...", new ImageView( new Image("icon/UPDATE_MARKET_DATA.png")));
    itemUpdateMarketData.setAccelerator(KeyCombination.keyCombination("Ctrl + U"));
    itemUpdateMarketData.setId("menuText");
    EventHandler<ActionEvent> actionUpdateMarketData = onDataUpdateAction(application, fm, config);
    itemUpdateMarketData.setOnAction(actionUpdateMarketData);
           
    //Create open market data item suit
    MenuItem itemOpenMarketData = new MenuItem("Open market data", new ImageView( new Image("icon/OPEN_FOLDER.png")));
    itemOpenMarketData.setAccelerator(KeyCombination.keyCombination("Ctrl + O"));
    itemOpenMarketData.setId("menuText");
    EventHandler<ActionEvent> onOpenMarketDataAction = onOpenMarketDataAction();
    itemOpenMarketData.setOnAction(onOpenMarketDataAction);
    
    //Create exit applictin menue item suit
    MenuItem itemExit = new MenuItem("Exit");
    itemExit.setId("menuText");
    EventHandler<ActionEvent> actionExit = onExitAction();
    itemExit.setOnAction(actionExit);
    
    fileMenu.getItems().addAll(
            itemLoadMarketData, 
            itemUpdateMarketData,
            itemOpenMarketData,
            new SeparatorMenuItem(), itemExit);
    /**
     * Create Chart menu
     */
    Menu chartMenu = new Menu("Chart");
    Menu chartDispplayMenu = new Menu("Display Setting");
    Menu chartOpenModeMenu = new Menu("Open Mode Setting");
    
    MenuItem itemChartColor = new MenuItem("Chart color setting", new ImageView( new Image("icon/COLOR.png")));
    itemChartColor.setId("menuText");
    EventHandler<ActionEvent> onOpenChartColorAction = onOpenChartColorAction();
    itemChartColor.setOnAction(onOpenChartColorAction);
    
    MenuItem itemChartBar = new MenuItem("Chart bar setting", new ImageView( new Image("icon/BAR_CHART_SETTING.png")));
    itemChartBar.setId("menuText");
    EventHandler<ActionEvent> onOpenChartBarAction = onOpenChartBarAction();
    itemChartBar.setOnAction(onOpenChartBarAction);
    
    MenuItem itemChartLine = new MenuItem("Line chart setting", new ImageView( new Image("icon/LINE_CHART_BLACK.png")));
    itemChartLine.setId("menuText");
    EventHandler<ActionEvent> onOpenChartLineAction = onOpenChartLineAction();
    itemChartLine.setOnAction(onOpenChartLineAction);
    
    MenuItem itemChartGann = new MenuItem("Gann swing chart setting", new ImageView( new Image("icon/CHANGE_BLUE.png")));
    itemChartGann.setId("menuText");
    EventHandler<ActionEvent> onOpenChartGannAction = onOpenChartGannAction();
    itemChartGann.setOnAction(onOpenChartGannAction);      
    
    chartMenu.getItems().addAll(chartDispplayMenu, chartOpenModeMenu);
    chartDispplayMenu.getItems().addAll(itemChartColor, itemChartBar, itemChartLine, itemChartGann);
    /**
     * Create Help Menu
     */
    Menu helpMenu = new Menu("Help");
    
    menuBar.getMenus().addAll(fileMenu,chartMenu, helpMenu);
    return menuBar;
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:82,代码来源:MenuCreator.java

示例13: getMenuItem

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
/**
 * 创建菜单项
 *
 * @param name
 * @param id
 * @return
 */
private MenuItem getMenuItem(String name, String id) {
    MenuItem item = new MenuItem(name);
    item.setId(id);
    item.setOnAction(new MenuHandler());
    return item;
}
 
开发者ID:cmlanche,项目名称:javafx-qiniu-tinypng-client,代码行数:14,代码来源:MainView.java


注:本文中的javafx.scene.control.MenuItem.setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。