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