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


Java MenuItem.setOnAction方法代码示例

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


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

示例1: createMenuAdd

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private MenuItem createMenuAdd() {
	final MenuItem menuAdd = new MenuItem("Add");
	menuAdd.setOnAction(event -> {
		final TextInputDialog dialog = new TextInputDialog();
		dialog.setTitle("Custom Tag Input Dialog");
		dialog.setHeaderText("New Custom Tag");
		dialog.setContentText("Name:");
		final Optional<String> result = dialog.showAndWait();
		if (result.isPresent()) {
			final String tagName = StringType.nvl(result.get());
			if (!tagName.isEmpty()) {
				if (MODEL.tagsProperty().filtered(t -> tagName.equals(t.getName())).isEmpty()) {
					final MetaTagModel metaTagModel = new MetaTagModel(tagName);
					if (null != MODEL.getOnAddTag()) {
						MODEL.getOnAddTag().accept(metaTagModel);
					}
					MODEL.tagsProperty().add(metaTagModel);
				}
			}
		}
	});
	return menuAdd;
}
 
开发者ID:mikelaud,项目名称:fx-media-tags,代码行数:24,代码来源:FxMediaTags.java

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

示例3: dataItem

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private MenuItem dataItem() {
    MenuItem data = new MenuItem(localeService.getMessage("ui.editor.tables.context.data"));
    data.setOnAction(event -> {
        dataAction.run();
        TableListContext.this.hide();
    });
    return data;
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:9,代码来源:TableListContext.java

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

示例5: getContextMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
@Override
public ContextMenu getContextMenu()
{
  MenuItem addInbox = new MenuItem("Data Domain Menu");
  addInbox.setOnAction(event -> LOGGER.debug("Data Domain Context Menu Event: " + event));
  return new ContextMenu(addInbox);
}
 
开发者ID:apache,项目名称:cayenne-modeler,代码行数:8,代码来源:DataDomainTreeItem.java

示例6: onStart

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
@Override
public void onStart() {
	root.prefWidthProperty().bind(Main.mainController.contentBox.widthProperty());
	root.prefHeightProperty().bind(Main.mainController.contentBox.heightProperty());
	gridView.setCellHeight(192);
	gridView.setCellWidth(192);
	gridView.setHorizontalCellSpacing(6);
	gridView.setVerticalCellSpacing(6);
	gridView.setCellFactory(param -> {
		GridCell<Instance> cell = new GridCell<>();
		cell.itemProperty().addListener((obs, oldItem, newItem) -> {
			if (newItem != null) {
				cell.setGraphic(new InstanceTile(newItem));
			}
		});
		cell.emptyProperty().addListener((obs, wasEmpty, isEmpty) -> {
			if (isEmpty) {
				cell.setGraphic(null);
			}
		});
		cell.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
		return cell;
	});

	new Thread(() -> {
		ObservableList<Instance> instances = InstanceManager.getInstances();
		MiscUtil.runLaterIfNeeded(() -> gridView.setItems(instances));
	}).start();
	ContextMenu menu = new ContextMenu();
	MenuItem open = new MenuItem("Open Instance Folder");
	menu.getItems().addAll(open);
	open.setOnAction(event -> OperatingSystem.openWithSystem(Constants.INSTANCEDIR));
	gridView.setContextMenu(menu);
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:35,代码来源:InstancesPane.java

示例7: ddlItem

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private MenuItem ddlItem() {
    MenuItem ddl = new MenuItem(localeService.getMessage("ui.editor.tables.context.ddl"));
    ddl.setOnAction(event -> {
        ddlAction.run();
        TableListContext.this.hide();
    });
    return ddl;
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:9,代码来源:TableListContext.java

示例8: createViewMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private Menu createViewMenu()
{
	Menu viewMenu = new Menu("View");
	
	MenuItem itemClearOutput = new MenuItem("Clear Output Pane");
	itemClearOutput.setAccelerator(new KeyCodeCombination(KeyCode.D,
			KeyCombination.CONTROL_DOWN));
	itemClearOutput.setOnAction((e) -> controller.clearConsole());
	
	viewMenu.getItems().addAll(itemClearOutput);
	return viewMenu;
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:13,代码来源:PLPToolMenuBarPanel.java

示例9: createShowAsMenuItem

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private MenuItem createShowAsMenuItem(String componentName, DataSource<?> source) {
  MenuItem menuItem = new MenuItem("Show as: " + componentName);
  menuItem.setOnAction(action -> {
    Components.getDefault().createComponent(componentName, source)
        .ifPresent(dashboard::addComponentToActivePane);
  });
  return menuItem;
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:9,代码来源:MainWindowController.java

示例10: createHelpMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private Menu createHelpMenu()
{
	Menu helpMenu = new Menu("Help");
	MenuItem itemQuickRef = new MenuItem("Quick Reference");
	itemQuickRef.setAccelerator(new KeyCodeCombination(KeyCode.F1));
	itemQuickRef.setOnAction((e) -> controller.showQuickReference());
	
	MenuItem itemOnlineManual = new MenuItem("Online Manual");
	itemOnlineManual.setOnAction((e) -> controller.showOnlineManual());
	
	MenuItem itemReportIssue = new MenuItem("Report Issue (Requires Google Account");
	itemReportIssue.setOnAction((e) -> controller.reportIssue());
	
	MenuItem itemIssuesPage = new MenuItem("Open Issues Page");
	itemIssuesPage.setOnAction((e) -> controller.showIssuesPage());
	
	MenuItem itemAboutPLP = new MenuItem("About PLP Tool...");
	itemAboutPLP.setOnAction((e) -> controller.showAboutPLPTool());
	
	MenuItem itemSWLicense = new MenuItem("Third Party Software License");
	itemSWLicense.setOnAction((e) -> controller.showThirdPartyLicenses());
	
	helpMenu.getItems().addAll(itemQuickRef, itemOnlineManual,
			new SeparatorMenuItem(), itemReportIssue, itemIssuesPage,
			new SeparatorMenuItem(), itemAboutPLP, itemSWLicense);
	
	return helpMenu;
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:29,代码来源:PLPToolMenuBarPanel.java

示例11: createMenuRename

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private MenuItem createMenuRename() {
	final MenuItem menuRename = new MenuItem("Rename");
	menuRename.setOnAction(event -> {
		final MetaTagModel metaTagModel = TAGS_TABLE.getSelectionModel().getSelectedItem();
		if (null != metaTagModel) {
			if (null != MODEL.getOnRenameTag()) {
				MODEL.getOnRenameTag().accept(metaTagModel);
			}
			//MODEL.tagsProperty().remove(metaTagModel);
		}
	});
	return menuRename;
}
 
开发者ID:mikelaud,项目名称:fx-media-tags,代码行数:14,代码来源:FxMediaTags.java

示例12: getContextMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
@Override
public ContextMenu getContextMenu()
{
  MenuItem addInbox = new MenuItem("Database Entity Menu");
  addInbox.setOnAction(event -> LOGGER.debug("Database Entity Context Menu Event: " + event));
  return new ContextMenu(addInbox);
}
 
开发者ID:apache,项目名称:cayenne-modeler,代码行数:8,代码来源:DatabaseEntityTreeItem.java

示例13: HelpMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public HelpMenu() {
    super("_Help");
    this.setMnemonicParsing(true);

    MenuItem about = new MenuItem("About");
    about.setOnAction(event -> ViewerAboutDialog.show());

    this.getItems().add(about);
}
 
开发者ID:Glavo,项目名称:ClassViewer,代码行数:10,代码来源:ViewerMenuBar.java

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

示例15: openInNewTabMenu

import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public MenuItem openInNewTabMenu(Viewer viewer) {
    MenuItem menu = new MenuItem("Open in new Tab");
    menu.setStyle(FontUtils.setUIFont(menu.getStyle()));
    menu.setOnAction(event -> viewer.openFile(getUrl()));
    return menu;
}
 
开发者ID:Glavo,项目名称:ClassViewer,代码行数:7,代码来源:FileTreeNode.java


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