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


Java MenuItem类代码示例

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


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

示例1: start

import javafx.scene.control.MenuItem; //导入依赖的package包/类
@Override
	public void start(Stage stage) {
		stage.setTitle("Vokabeltrainer");
        Scene scene = new Scene(new VBox(), 400, 350);
        scene.setFill(Color.OLDLACE);
 
        MenuBar menuBar = new MenuBar();
 
        // --- Menu File
        Menu menuFile = new Menu("Vokabeln");
        
        MenuItem sample = new MenuItem("Sample");
        sample.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
//				Do stuff here
			}
		});
        
        menuFile.getItems().add(sample);
 
        // --- Menu Edit
        Menu menuEdit = new Menu("Abfragemodus");
 
        // --- Menu View
        Menu menuView = new Menu("Statistik");
 
        menuBar.getMenus().addAll(menuFile, menuEdit, menuView);
 
 
        ((VBox) scene.getRoot()).getChildren().addAll(menuBar);
 
        stage.setScene(scene);
        stage.show();
	}
 
开发者ID:dunkelziffer,项目名称:Vokabeltrainer,代码行数:36,代码来源:Main.java

示例2: getContextMenu

import javafx.scene.control.MenuItem; //导入依赖的package包/类
@Override
public ContextMenu getContextMenu()
{
    ContextMenu contextMenu  = new ContextMenu();
    ObjEntity   objectEntity = (ObjEntity) getPropertyAdapter().getWrappedObject();

    getPropertyAdapter().getDataMapAdapter().getDatabaseEntityAdapters().stream().forEach(databaseEntity ->
        {
            if (StringUtils.equals(databaseEntity.getName(), objectEntity.getDbEntityName()))
            {
                MenuItem jumpTo = new MenuItem("Jump To Database Entity: " + databaseEntity.getName());

                jumpTo.setMnemonicParsing(false);
                jumpTo.setOnAction(event ->
                    {
                        LOGGER.debug("Jumping to DB Entity: " + databaseEntity.getName());
                    });

                contextMenu.getItems().add(jumpTo);
            }
        });

  return contextMenu;
}
 
开发者ID:apache,项目名称:cayenne-modeler,代码行数:25,代码来源:ObjectEntityTreeItem.java

示例3: build

import javafx.scene.control.MenuItem; //导入依赖的package包/类
public Button build(String name, Association association) {

        EventBus eventBus = toolBox.getEventBus();

        Button button = new JFXButton(name);
        button.setUserData(association);
        button.getStyleClass().add("abpanel-button");
        button.setOnAction(event -> {
            ArrayList<Annotation> annotations = new ArrayList<>(toolBox.getData().getSelectedAnnotations());
            eventBus.send(new CreateAssociationsCmd(association, annotations));
        });
        button.setTooltip(new Tooltip(association.toString()));

        ContextMenu contextMenu = new ContextMenu();
        MenuItem deleteButton = new MenuItem(toolBox.getI18nBundle().getString("cbpanel.conceptbutton.delete"));
        deleteButton.setOnAction(event ->
                ((Pane) button.getParent()).getChildren().remove(button));
        contextMenu.getItems().addAll(deleteButton);
        button.setContextMenu(contextMenu);

        return button;

    }
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:24,代码来源:AssocButtonFactory.java

示例4: createURLLink

import javafx.scene.control.MenuItem; //导入依赖的package包/类
private void createURLLink(String pattern, String id, String icon) {
    MenuItem tmsMenuItem = new MenuItem(id, FXUIUtils.getIcon(icon));
    if (pattern != null && pattern.length() > 0) {
        String url = String.format(pattern, id);
        tmsMenuItem.setOnAction((event) -> {
            try {
                Desktop.getDesktop().browse(new URI(url));
            } catch (IOException | URISyntaxException e) {
                e.printStackTrace();
            }
        });
    } else {
        tmsMenuItem.setDisable(true);
    }
    infoButton.getItems().add(tmsMenuItem);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:17,代码来源:ACEEditor.java

示例5: fillContextMenu

import javafx.scene.control.MenuItem; //导入依赖的package包/类
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree,
                            @NotNull final ObservableList<MenuItem> items) {
    if (!(nodeTree instanceof ModelNodeTree)) return;

    final T element = getElement();
    final AssetLinkNode linkNode = findParent(element, AssetLinkNode.class::isInstance);

    if (linkNode == null) {
        final Menu createMenu = createCreationMenu(nodeTree);
        if (createMenu != null) items.add(createMenu);
        final Menu toolMenu = createToolMenu(nodeTree);
        if (toolMenu != null) items.add(toolMenu);
    }

    if (linkNode == null || element == linkNode) {
        items.add(new AddUserDataAction(nodeTree, this));
    }

    if (canRemove()) {
        items.add(new RemoveNodeAction(nodeTree, this));
    }

    super.fillContextMenu(nodeTree, items);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:27,代码来源:SpatialTreeNode.java

示例6: getTagForMenu

import javafx.scene.control.MenuItem; //导入依赖的package包/类
private String getTagForMenu(MenuItem source) {
    LinkedList<MenuItem> menuItems = new LinkedList<>();
    while (source != null) {
        menuItems.addFirst(source);
        source = source.getParentMenu();
    }
    if (menuItems.getFirst() instanceof Menu) {
        if (menuItems.size() >= 2) {
            ownerNode = menuItems.get(1).getParentPopup().getOwnerNode();
            return isMenuBar(ownerNode) ? "#menu" : "#contextmenu";
        }
    } else {
        ownerNode = menuItems.getFirst().getParentPopup().getOwnerNode();
        return "#contextmenu";
    }
    return null;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:RFXMenuItem.java

示例7: updateMenuItems

import javafx.scene.control.MenuItem; //导入依赖的package包/类
private void updateMenuItems() {
    ToggleGroup group = new ToggleGroup();
    List<MenuItem> items = new ArrayList<>();
    for (Calendar calendar : getSkinnable().getCalendars()) {
        RadioMenuItem item = new RadioMenuItem(calendar.getName());
        Rectangle icon = new Rectangle(10, 10);
        icon.setArcHeight(2);
        icon.setArcWidth(2);
        icon.getStyleClass().add(calendar.getStyle() + "-icon"); //$NON-NLS-1$
        item.setGraphic(icon);
        item.setDisable(calendar.isReadOnly());
        item.setOnAction(evt -> getSkinnable().setCalendar(calendar));
        group.getToggles().add(item);
        items.add(item);
        if (calendar.equals(getSkinnable().getCalendar())) {
            item.setSelected(true);
        }
    }

    button.getItems().setAll(items);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:22,代码来源:CalendarSelectorSkin.java

示例8: GoogleEntryAttendeeItem

import javafx.scene.control.MenuItem; //导入依赖的package包/类
public GoogleEntryAttendeeItem(EventAttendee attendee) {
    this.attendee = Objects.requireNonNull(attendee);

    optionalIcon = new Label();
    optionalIcon.setOnMouseClicked(evt -> setOptional(!isOptional()));
    optionalIcon.getStyleClass().add("button-icon");
    optionalIcon.setTooltip(new Tooltip());

    statusIcon = new Label();

    name = new Label();
    name.setMaxWidth(Double.MAX_VALUE);

    setOptional(Boolean.TRUE.equals(attendee.getOptional()));
    optionalProperty().addListener(obs -> updateIcon());
    updateIcon();

    removeButton = new Label();
    removeButton.setGraphic(new FontAwesome().create(FontAwesome.Glyph.TRASH_ALT));
    removeButton.getStyleClass().add("button-icon");
    removeButton.setOnMouseClicked(evt -> removeAttendee(attendee));

    HBox.setHgrow(optionalIcon, Priority.NEVER);
    HBox.setHgrow(name, Priority.ALWAYS);
    HBox.setHgrow(removeButton, Priority.NEVER);

    getStyleClass().add("attendee-item");
    getChildren().addAll(optionalIcon, statusIcon, name, removeButton);

    ContextMenu menu = new ContextMenu();
    MenuItem optionalItem = new MenuItem("Mark as optional");
    optionalItem.setOnAction(evt -> setOptional(true));
    MenuItem requiredItem = new MenuItem("Mark as required");
    requiredItem.setOnAction(evt -> setOptional(false));
    MenuItem removeItem = new MenuItem("Remove attendee");
    removeItem.setOnAction(evt -> removeAttendee(attendee));
    menu.getItems().addAll(optionalItem, requiredItem, new SeparatorMenuItem(), removeItem);

    addEventHandler(CONTEXT_MENU_REQUESTED, evt -> menu.show(this, evt.getScreenX(), evt.getScreenY()));
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:41,代码来源:GoogleEntryAttendeesView.java

示例9: subMenuPath

import javafx.scene.control.MenuItem; //导入依赖的package包/类
@Test public void subMenuPath() {
    List<String> path = new ArrayList<>();
    Platform.runLater(() -> {
        Menu menuEdit = new Menu("Edit");
        Menu menuEffect = new Menu("Picture Effect");

        final MenuItem noEffects = new MenuItem("No Effects");

        menuEdit.getItems().addAll(menuEffect, noEffects);
        MenuItem add = new MenuItem("Shuffle");
        menuEffect.getItems().addAll(add);
        RFXMenuItem rfxMenuItem = new RFXMenuItem(null, null);
        path.add(rfxMenuItem.getSelectedMenuPath(add));
    });
    new Wait("Waiting for menu selection path") {
        @Override public boolean until() {
            return path.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Edit>>Picture Effect>>Shuffle", path.get(0));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:22,代码来源:RFXMenuItemTest.java

示例10: populateExamples

import javafx.scene.control.MenuItem; //导入依赖的package包/类
private void populateExamples() {
    val map = new LinkedHashMap<String, String>();
    map.put("HotaruFX Logo", "hotarufx-logo.hfx");
    map.put("Font Awesome Icons", "font-awesome.hfx");
    map.put("HSV Color", "hsv.hfx");
    map.put("Line", "line.hfx");
    map.put("Rectangle", "rectangle.hfx");
    map.put("Round Rectangle", "round-rect.hfx");
    map.put("Font", "font.hfx");
    map.put("Image", "image.hfx");
    map.put("Image Rotate & Zoom", "image_rotate_zoom.hfx");
    map.put("Text Clipping", "clip-text.hfx");
    map.put("Blend Modes", "blend-modes.hfx");
    map.put("Stroke Ants", "stroke-ants.hfx");
    examplesMenu.getItems().clear();
    for (val entry : map.entrySet()) {
        val item = new MenuItem(entry.getKey());
        item.setOnAction(e -> openExample("/examples/" + entry.getValue()));
        examplesMenu.getItems().add(item);
    }
}
 
开发者ID:aNNiMON,项目名称:HotaruFX,代码行数:22,代码来源:EditorController.java

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

示例12: TextPaneMenu

import javafx.scene.control.MenuItem; //导入依赖的package包/类
public TextPaneMenu(TextArea textArea) {
    this.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()
        );

        clipboard.setContents(s, null);
    });
    copy.setGraphic(new ImageView(ImageUtils.copyImage));

    getItems().addAll(copy);
}
 
开发者ID:Glavo,项目名称:ClassViewer,代码行数:19,代码来源:TextPaneMenu.java

示例13: AsciiPaneMenu

import javafx.scene.control.MenuItem; //导入依赖的package包/类
public AsciiPaneMenu(TextArea textArea) {
    this.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,代码行数:19,代码来源:AsciiPaneMenu.java

示例14: load

import javafx.scene.control.MenuItem; //导入依赖的package包/类
@Override
public void load() {
    super.load();
    Platform.runLater(new Runnable() { // this will run initFX as JavaFX-Thread
        @Override
        public void run() {
            webView.setContextMenuEnabled(false);
            contextMenu = new ContextMenu();
            open = new MenuItem("Open in browser");
            addActionListener();
            addContextMenuListener();
            contextMenu.getItems().addAll(open);
        }
    });

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:HelpBrowser.java

示例15: handle

import javafx.scene.control.MenuItem; //导入依赖的package包/类
@Override
public void handle(ActionEvent event)
{   
    GoliathOUFX.scene.getStylesheets().remove(0);
    
    switch(((MenuItem)event.getSource()).getText())
    {
        case "Magma":
            GoliathOUFX.scene.getStylesheets().add("skins/Goliath-Magma.css");
            break;
            
        case "Arc":
            GoliathOUFX.scene.getStylesheets().add("skins/Goliath-Arc.css");
            break;   
    }
}
 
开发者ID:BlueGoliath,项目名称:Goliath-Overclocking-Utility-FX,代码行数:17,代码来源:ThemesMenu.java


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