當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。