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


Java CustomMenuItem.setOnAction方法代码示例

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


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

示例1: populatePopup

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
/**
 * Populate the entry set with the given search results.  Display is limited to 10 entries, for performance.
 *
 * @param searchResult The set of matching strings.
 */
private void populatePopup(List<String> searchResult) {
    List<CustomMenuItem> menuItems = new LinkedList<>();
    // If you'd like more entries, modify this line.
    int maxEntries = 10;
    int count = Math.min(searchResult.size(), maxEntries);
    for (int i = 0; i < count; i++) {
        final String result = searchResult.get(i);
        Label entryLabel = new Label(result);
        CustomMenuItem item = new CustomMenuItem(entryLabel, true);
        item.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                textInputControl.setText(result); //todo add word
                entriesPopup.hide();
            }
        });
        menuItems.add(item);
    }
    entriesPopup.getItems().clear();
    entriesPopup.getItems().addAll(menuItems);

}
 
开发者ID:iazarny,项目名称:gitember,代码行数:28,代码来源:ChangeListenerHistoryHint.java

示例2: populatePopup

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
/**
 * Populate the entry set with the given search results.  Display is limited to 10 entries, for performance.
 * @param searchResult The set of matching strings.
 */
private void populatePopup(List<String> searchResult) {
  List<CustomMenuItem> menuItems = new LinkedList<>();
  // If you'd like more entries, modify this line.
  int maxEntries = 10;
  int count = Math.min(searchResult.size(), maxEntries);
  for (int i = 0; i < count; i++)
  {
    final String result = searchResult.get(i);
    Label entryLabel = new Label(result);
    CustomMenuItem item = new CustomMenuItem(entryLabel, true);
    item.setOnAction(new EventHandler<ActionEvent>()
    {
      @Override
      public void handle(ActionEvent actionEvent) {
      	getEditor().setText(result);
        entriesPopup.hide();
      }
    });
    menuItems.add(item);
  }
  entriesPopup.getItems().clear();
  entriesPopup.getItems().addAll(menuItems);

}
 
开发者ID:thirdy,项目名称:blackmarket,代码行数:29,代码来源:AutoCompleteComboBox.java

示例3: popularPopup

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
private void popularPopup(ObservableList<T> lista_itens) {
    int maximoItens = 18;
    int contador = Math.min(lista_itens.size(), maximoItens);
    List<CustomMenuItem> popupItens = new LinkedList<>();
    for (int i = 0; i < contador; i++) {
        final T item = lista_itens.get(i);
        Label itemLabel = new Label(item.toString());
        CustomMenuItem menuItem = new CustomMenuItem(itemLabel, true);
        menuItem.setOnAction(actionEvent -> {
            setText(item.toString());
            popup.hide();
            if (controlador != null) {
                controladorF.adicionar(null);
            }
        });
        popupItens.add(menuItem);
    }
    popup.getItems().clear();
    popup.getItems().addAll(popupItens);
}
 
开发者ID:badernageral,项目名称:bgfinancas,代码行数:21,代码来源:AutoCompletarTextField.java

示例4: populatePopup

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
/**
 * Populate the entry set with the given search results. Display is limited
 * to 10 entries, for performance.
 * 
 * @param searchResult
 *            The set of matching strings.
 */
private void populatePopup(List<String> searchResult) {
	List<CustomMenuItem> menuItems = new LinkedList<>();
	// If you'd like more entries, modify this line.
	int maxEntries = 10;
	int count = Math.min(searchResult.size(), maxEntries);
	for (int i = 0; i < count; i++) {
		final String result = searchResult.get(i);
		Label entryLabel = new Label(result);
		CustomMenuItem item = new CustomMenuItem(entryLabel, true);
		item.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent actionEvent) {
				setText(result);
				entriesPopup.hide();
			}
		});
		menuItems.add(item);
	}
	entriesPopup.getItems().clear();
	entriesPopup.getItems().addAll(menuItems);
}
 
开发者ID:Co0sh,项目名称:BetonQuest-Editor,代码行数:29,代码来源:AutoCompleteTextField.java

示例5: createCMForStructureViewList

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
public static ContextMenu createCMForStructureViewList(ListView<Actor> listView) {
	ContextMenu cm = new ContextMenu();
	CustomMenuItem addActorMenuItem = GUIUtil.createTooltipedMenuItem("Add new",
			"Create new global Actor and add it to currently selected SisScene.\n\n"
					+ aboutActor);
	Menu addExistingActorMenuItem = generateAddExistingActorMenu(false);
	addActorMenuItem.setOnAction((ActionEvent event) -> {
		addNewActor();
	});
	cm.getItems().addAll(addActorMenuItem);
	if (addExistingActorMenuItem.getItems().size() != 0) {
		cm.getItems().add(addExistingActorMenuItem);
	}
	cm.autoHideProperty().set(true);
	return cm;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:17,代码来源:ActorContextMenuBuilder.java

示例6: getSuggestion

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
CustomMenuItem getSuggestion(String suggestion) {
    Label entryLabel = new Label(suggestion);
    CustomMenuItem item = new CustomMenuItem(entryLabel, true);
    item.setOnAction(f -> {
        addPrincipal.setText(suggestion);
    });
    return item;
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:9,代码来源:GetUpdatePolicies.java

示例7: getCompletionMenuItem

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
private MenuItem getCompletionMenuItem(final String name, final String oldText, final int startInd, final String completion, final Node graphic) {
	Label label = new Label(name);
	label.setMaxWidth(Double.POSITIVE_INFINITY);
	CustomMenuItem item = new CustomMenuItem(label);
	item.setOnAction(e -> {
		currentText.set(oldText.substring(0, startInd) + completion);
		textAreaInput.appendText("");
		updateLastHistoryListEntry();
	});
	if (graphic != null) {
		label.setContentDisplay(ContentDisplay.RIGHT);
		label.setGraphic(graphic);
	}
	return item;
}
 
开发者ID:qupath,项目名称:qupath,代码行数:16,代码来源:ScriptInterpreterCommand.java

示例8: generateAddExistingActorMenu

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
private static Menu generateAddExistingActorMenu(boolean onItem) {
	String menuText;
	if (onItem) {
		menuText = "Add existing Actor below...";
	} else {
		menuText = "Add existing...";
	}
	Menu addExistingActorMenu = new Menu(menuText);
	ArrayList<Actor> existingActors = new ArrayList<Actor>(
			ProjectManager.getProject().getGlobalActorsUnmodifiable());
	ObservableList<Actor> currentActors = ProjectManager.getProject().getCurrentActorsUnmodifiable();
	existingActors.removeAll(currentActors);
	for (Actor actor : existingActors) {
		ElementInfo info = actor.getElementInfo();
		String params = "Name: " + info.getName() + "\nCheck Interval: "
				+ actor.getCheckInterval() + " ms\nRepeat Interval: "
				+ actor.getRepeatInterval() + " ms\nRepeat On Actions: " + actor.getDoOnRepeat()
				+ "\nRepeat Off Actions: " + actor.getDoOffRepeat() + "\nIs broken: "
				+ actor.getElementInfo().isBroken();
		CustomMenuItem existingActorMenuItem = GUIUtil
				.createTooltipedMenuItem(actor.getElementInfo().getName(), params);
		existingActorMenuItem.setOnAction((ActionEvent event) -> {
			ProjectManager.getProject().addExistingActorToCurrentSisScene(actor);
		});
		addExistingActorMenu.getItems().add(existingActorMenuItem);
	}
	return addExistingActorMenu;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:29,代码来源:ActorContextMenuBuilder.java

示例9: createSisSceneListContextMenu

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
public static ContextMenu createSisSceneListContextMenu() {
	ContextMenu cm = new ContextMenu();
	CustomMenuItem addSisSceneMenuItem = GUIUtil.createTooltipedMenuItem("Add new",
			"Add new SisScene in which you can add Actors later.\n\n" + aboutSisScene);
	addSisSceneMenuItem.setOnAction((ActionEvent event) -> {
		addSisScene();
	});
	cm.getItems().add(addSisSceneMenuItem);
	cm.autoHideProperty().set(true);
	return cm;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:12,代码来源:SisSceneContextMenuBuilder.java

示例10: CustomizedTreeCell

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
public CustomizedTreeCell(IFileEventManager fileEventManager,
		Provider<IFileRecoveryHandler> recoverFileHandlerProvider,
		Provider<IShareFolderHandler> shareFolderHandlerProvider,
		Provider<IForceSyncHandler> forceSyncHandlerProvider){

	this.fileEventManager = fileEventManager;
	this.shareFolderHandlerProvider = shareFolderHandlerProvider;
	this.recoverFileHandlerProvider = recoverFileHandlerProvider;
	this.forceSyncHandlerProvider = forceSyncHandlerProvider;

	menu = new ContextMenu();

	deleteItem = new CustomMenuItem(new Label("Delete from network"));
	deleteItem.setOnAction(new DeleteAction());
	menu.getItems().add(deleteItem);

	shareItem = new CustomMenuItem(new Label("Share"));
	shareItem.setOnAction(new ShareFolderAction());
	menu.getItems().add(shareItem);

	propertiesItem = new MenuItem("Properties");
	propertiesItem.setOnAction(new ShowPropertiesAction());
	menu.getItems().add(propertiesItem);

	forceSyncItem = new MenuItem("Force synchronization");
	forceSyncItem.setOnAction(new ForceSyncAction());
	menu.getItems().add(forceSyncItem);

	recoverMenuItem = createRecoveMenuItem();
	menu.getItems().add(recoverMenuItem);

	menu.setOnShowing(new ShowMenuHandler());
       setContextMenu(menu);
}
 
开发者ID:PeerWasp,项目名称:PeerWasp,代码行数:35,代码来源:CustomizedTreeCell.java

示例11: ConversionMenu

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
public ConversionMenu(StringProperty text) {
    super(Localization.lang("Convert"));

    // create menu items, one for each converter
    for (Formatter converter : Formatters.CONVERTERS) {
        CustomMenuItem menuItem = new CustomMenuItem(new Label(converter.getName()));
        Tooltip toolTip = new Tooltip(converter.getDescription());
        Tooltip.install(menuItem.getContent(), toolTip);
        menuItem.setOnAction(event -> text.set(converter.format(text.get())));
        this.getItems().add(menuItem);
    }
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:13,代码来源:ConversionMenu.java

示例12: getNameMenu

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
/**
 * The default context menu with a specific menu for normalizing person names regarding to BibTex rules.
 *
 * @param textArea text-area that this menu will be connected to
 * @return menu containing items of the default menu and an item for normalizing person names
 */
public static Supplier<List<MenuItem>> getNameMenu(TextArea textArea) {
    return () -> {
        CustomMenuItem normalizeNames = new CustomMenuItem(new Label(Localization.lang("Normalize to BibTeX name format")));
        normalizeNames.setOnAction(event -> textArea.setText(new NormalizeNamesFormatter().format(textArea.getText())));
        Tooltip toolTip = new Tooltip(Localization.lang("If possible, normalize this list of names to conform to standard BibTeX name formatting"));
        Tooltip.install(normalizeNames.getContent(), toolTip);
        List<MenuItem> menuItems = new ArrayList<>(6);
        menuItems.add(normalizeNames);
        menuItems.addAll(getDefaultMenu(textArea).get());
        return menuItems;
    };
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:19,代码来源:EditorMenus.java

示例13: CaseChangeMenu

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
public CaseChangeMenu(final StringProperty text) {
    super(Localization.lang("Change case"));
    Objects.requireNonNull(text);

    // create menu items, one for each case changer
    for (final Formatter caseChanger : Formatters.CASE_CHANGERS) {
        CustomMenuItem menuItem = new CustomMenuItem(new Label(caseChanger.getName()));
        Tooltip toolTip = new Tooltip(caseChanger.getDescription());
        Tooltip.install(menuItem.getContent(), toolTip);
        menuItem.setOnAction(event -> text.set(caseChanger.format(text.get())));

        this.getItems().add(menuItem);
    }
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:15,代码来源:CaseChangeMenu.java

示例14: createCuteTreeCellContextMenu

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
/**
 * Creates the {@link ContextMenu} for the chosen {@link CuteTreeCell}.
 *
 * @param treeCell
 *            the CuteTreeCell for which ContextMenu will be created.
 * @return the ContextMenu
 */
public static ContextMenu createCuteTreeCellContextMenu(CuteTreeCell treeCell) {
	CuteElement cuteElement = (CuteElement) treeCell.getItem();
	if (cuteElement == null)
		return null;
	ContextMenu cm = new ContextMenu();
	CustomMenuItem moveUpMenuItem = GUIUtil.createTooltipedMenuItem("Move Up",
			"This will move the thingy Up");
	moveUpMenuItem.setOnAction(createMovementEventHandler(treeCell, true));
	CustomMenuItem moveDownMenuItem = GUIUtil.createTooltipedMenuItem("Move Down",
			"This will move the thingy Down");
	moveDownMenuItem.setOnAction(createMovementEventHandler(treeCell, false));
	CustomMenuItem deleteMenuItem = GUIUtil.createTooltipedMenuItem("Delete",
			"Are you sure?\nAre you going to throw this little item away..?");
	deleteMenuItem.setOnAction((ActionEvent event) -> {
		ObservableList<? extends CuteElement> list = treeCell.getTreeItem().getParent()
				.getValue().getChildren();
		if (list != null) {
			if (!list.isEmpty()) {
				if (list.contains(cuteElement)) {
					list.remove(cuteElement);
					// Initialize whole project to reinitialize any parents that might get
					// broken.
					ProjectManager.initProjectFromGUI();
				} else {
					logger.error("Nothing to remove from list");
				}
			} else {
				logger.error("list is empty");
			}
		} else {
			logger.error("list is null");
		}
	});

	// Let's determine where the Item can move.
	// By default let's have ability to move in both directions.
	PossibleMoves possibleMoves = PossibleMoves.UPORDOWN;
	TreeItem<CuteElement> treeItem = treeCell.getTreeItem();
	int treeItemIndex = treeItem.getParent().getChildren().indexOf(treeItem);
	int sizeOfList = treeItem.getParent().getChildren().size();
	if (sizeOfList != 1) {
		if (treeItemIndex == 0)
			possibleMoves = PossibleMoves.ONLYDOWN;
		if (treeItemIndex == sizeOfList - 1)
			possibleMoves = PossibleMoves.ONLYUP;
	} else {
		possibleMoves = PossibleMoves.NOWHERE;
	}

	// Let's add all MenuItems to Context Menu
	if (canChildrenBeAdded(cuteElement)) {
		cm.getItems().add(generateNewCuteElementMenu(cuteElement));
	}
	if (!possibleMoves.equals(PossibleMoves.NOWHERE)) {
		if (possibleMoves.equals(PossibleMoves.UPORDOWN)) {
			cm.getItems().add(moveUpMenuItem);
			cm.getItems().add(moveDownMenuItem);
		} else {
			if (possibleMoves.equals(PossibleMoves.ONLYUP))
				cm.getItems().add(moveUpMenuItem);
			if (possibleMoves.equals(PossibleMoves.ONLYDOWN))
				cm.getItems().add(moveDownMenuItem);
		}
	}
	if (!CuteElement.MaxAddableChildrenCount.UNDEFINEDORZERO.equals(
			treeCell.getTreeItem().getParent().getValue().getMaxAddableChildrenCount())) {
		cm.getItems().add(deleteMenuItem);
	}
	cm.autoHideProperty().set(true);
	return cm;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:79,代码来源:TreeContextMenuBuilder.java

示例15: generateMenuForAddingNewContainer

import javafx.scene.control.CustomMenuItem; //导入方法依赖的package包/类
/**
 * Generate {@link Menu} for adding new {@link CuteElementContainer}s as children to the chosen
 * CuteElement.
 *
 * @param whereToAdd
 *            the CuteElement where to add new child using generated Menu
 * @return the Menu
 */
private static Menu generateMenuForAddingNewContainer(CuteElement whereToAdd) {
	ContainerCreationParams params = whereToAdd.getChildContainerCreationParams();
	Menu menu = new Menu("Add new " + params.containerFakeTypeName + "...");
	
	CustomMenuItem newContainerMenuItem = GUIUtil
			.createTooltipedMenuItem(params.containerFakeTypeName, params.GUIDescription);
	newContainerMenuItem.setOnAction((ActionEvent event) -> {
		CuteElement cuteElementContainerToAdd = null;
		
		// This list will later help to generate name for the new Container.
		List<String> existingChildrenNames = new ArrayList<String>();
		for (CuteElement element : whereToAdd.getChildren()) {
			existingChildrenNames.add(element.getElementInfo().getName());
		}
		
		try {
			// Determine proper name for new container
			String name = GUIUtil.generateUniqueNameForNewItem(params.creationBaseName,
					existingChildrenNames);
			// Instantiate Container
			cuteElementContainerToAdd = CuteElementContainer.createEmptyCuteElementContainer(
					name, params.childrenType, params.childrenMaxCount,
					params.childrenMinCount, params.containerFakeTypeName);
			cuteElementContainerToAdd.getElementInfo().setEditable(params.editable);
			cuteElementContainerToAdd.getElementInfo()
					.setEmptyNameAllowed(params.emptyNameAllowed);

		} catch (Exception e) {
			throw new RuntimeException("Can't instantiate Container inside "
					+ whereToAdd.getClass().getSimpleName(), e);
		}
		if (cuteElementContainerToAdd != null) {
			@SuppressWarnings("unchecked")
			ObservableList<CuteElement> whereToAddCasted = (ObservableList<CuteElement>) whereToAdd
					.getChildren();
			whereToAddCasted.add(cuteElementContainerToAdd);
			// Initialize whole project to reinitialize any parents that might get broken.
			ProjectManager.initProjectFromGUI();
		}
	});
	menu.getItems().add(newContainerMenuItem);
	return menu;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:52,代码来源:TreeContextMenuBuilder.java


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