本文整理汇总了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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}