Package javafx.scene.control

Examples of javafx.scene.control.MenuItem


    /**
     * Manage buttons and menu items
     */
    public void initDecoration() {
        MenuItem minimizeMenuItem = null;
        // Menu
        final ContextMenu contextMenu = new ContextMenu();
        contextMenu.setAutoHide(true);
        if (minimize != null) { // Utility Stage
            minimizeMenuItem = new MenuItem(LOC.getString("Minimize"));
            minimizeMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.M, KeyCombination.SHORTCUT_DOWN));

            minimizeMenuItem.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent e) {
                    switchMinimize();
                }
            });
            contextMenu.getItems().add(minimizeMenuItem);
        }
        if (maximize != null && stage.isResizable()) { // Utility Stage type
            maximizeMenuItem = new MenuItem(LOC.getString("Maximize"));
            maximizeMenuItem.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent e) {
                    switchMaximize();
                    contextMenu.hide(); // Stay stuck on screen
                }
            });
            contextMenu.getItems().addAll(maximizeMenuItem, new SeparatorMenuItem());
        }

        // Fullscreen
        if (stageStyle != StageStyle.UTILITY && stage.isResizable()) {
            fullScreenMenuItem = new CheckMenuItem(LOC.getString("FullScreen"));
            fullScreenMenuItem.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent e) {
                    // fake
                    //maximizeProperty().set(!maximizeProperty().get());
                    switchFullscreen();
                }
            });
            fullScreenMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN, KeyCombination.SHORTCUT_DOWN));

            contextMenu.getItems().addAll(fullScreenMenuItem, new SeparatorMenuItem());
        }

        // Close
        MenuItem closeMenuItem = new MenuItem(LOC.getString("Close"));
        closeMenuItem.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                switchClose();
            }
        });
        closeMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN));

        contextMenu.getItems().add(closeMenuItem);

        menu.setOnMousePressed(new EventHandler<MouseEvent>() {
            @Override
View Full Code Here


    /**
     * @param tn the value of tn
     */
    static public MenuItem createSelTagMenuItem(final TagName tn, final SplitMenuButton tagSelectedMenuButton) {
        final MenuItem menuItem = new MenuItem(tn.getDisplayName(), new ImageView(DrawableAttribute.TAGS.getIcon()));
        menuItem.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                AddDrawableTagAction.getInstance().addTag(tn, "");
                tagSelectedMenuButton.setText(tn.getDisplayName());
                tagSelectedMenuButton.setOnAction(this);
View Full Code Here

        tagSplitButton.setGraphic(new ImageView(DrawableAttribute.TAGS.getIcon()));
        tagSplitButton.showingProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> {
            if (t1) {
                ArrayList<MenuItem> selTagMenues = new ArrayList<>();
                for (final TagName tn : TagUtils.getNonCategoryTagNames()) {
                    MenuItem menuItem = TagUtils.createSelTagMenuItem(tn, tagSplitButton);
                    selTagMenues.add(menuItem);
                }
                tagSplitButton.getItems().setAll(selTagMenues);
            }
        });
View Full Code Here

            // Each category get an item in the sub-menu. Selecting one of these menu items adds
            // a tag with the associated category.
            for (final Category cat : Category.values()) {

                MenuItem categoryItem = new MenuItem(cat.getDisplayName());
                categoryItem.setOnAction((ActionEvent t) -> {
                    final CategorizeAction categorizeAction = new CategorizeAction();
                    categorizeAction.addTag(cat.getTagName(), NO_COMMENT);
                });
                categoryItem.setAccelerator(new KeyCodeCombination(cat.getHotKeycode()));
                getItems().add(categoryItem);
            }
        }
View Full Code Here

            // the "Quick Tags" sub-menu. Selecting one of these menu items adds
            // a tag with the associated tag name.
            if (null != tagNames && !tagNames.isEmpty()) {
                for (final TagName tagName : tagNames) {
                    if (tagName.getDisplayName().startsWith(Category.CATEGORY_PREFIX) == false) {
                        MenuItem tagNameItem = new MenuItem(tagName.getDisplayName());
                        tagNameItem.setOnAction((ActionEvent t) -> {
                            addTag(tagName, NO_COMMENT);
                            refreshDirectoryTree();
                        });
                        quickTagMenu.getItems().add(tagNameItem);
                    }
                }
            } else {
                MenuItem empty = new MenuItem("No tags");
                empty.setDisable(true);
                quickTagMenu.getItems().add(empty);
            }

            //   quickTagMenu.addSeparator();
            // The "Quick Tag" menu also gets an "Choose Tag..." menu item.
            // Selecting this item initiates a dialog that can be used to create
            // or select a tag name and adds a tag with the resulting name.
            MenuItem newTagMenuItem = new MenuItem("New Tag...");
            newTagMenuItem.setOnAction((ActionEvent t) -> {
                try {
                    SwingUtilities.invokeAndWait(() -> {
                        TagName tagName = GetTagNameDialog.doDialog();
                        if (tagName != null) {
                            addTag(tagName, NO_COMMENT);
                            refreshDirectoryTree();
                        }
                    });
                } catch (InterruptedException | InvocationTargetException ex) {
                    Exceptions.printStackTrace(ex);
                }
            });
            quickTagMenu.getItems().add(newTagMenuItem);

            // Create a "Choose Tag and Comment..." menu item. Selecting this item initiates
            // a dialog that can be used to create or select a tag name with an
            // optional comment and adds a tag with the resulting name.
            MenuItem tagAndCommentItem = new MenuItem("Tag and Comment...");
            tagAndCommentItem.setOnAction((ActionEvent t) -> {
                try {
                    SwingUtilities.invokeAndWait(() -> {
                        GetTagNameAndCommentDialog.TagNameAndComment tagNameAndComment = GetTagNameAndCommentDialog.doDialog();
                        if (null != tagNameAndComment) {
                            if (tagNameAndComment.getTagName().getDisplayName().startsWith(Category.CATEGORY_PREFIX)) {
View Full Code Here

                menuItems.add(CategorizeAction.getPopupMenu());

                menuItems.add(AddDrawableTagAction.getInstance().getPopupMenu());

                final MenuItem extractMenuItem = new MenuItem("Extract File(s)");
                extractMenuItem.setOnAction((ActionEvent t) -> {
                    SwingUtilities.invokeLater(() -> {
                        TopComponent etc = WindowManager.getDefault().findTopComponent(ImageAnalyzerTopComponent.PREFERRED_ID);
                        ExtractAction.getInstance().actionPerformed(new java.awt.event.ActionEvent(etc, 0, null));
                    });
                });
                menuItems.add(extractMenuItem);

                MenuItem contentViewer = new MenuItem("Show Content Viewer");
                contentViewer.setOnAction((ActionEvent t) -> {
                    SwingUtilities.invokeLater(() -> {
                        new NewWindowViewAction("Show Content Viewer", new FileNode(getFile().getAbstractFile())).actionPerformed(null);
                    });
                });
                menuItems.add(contentViewer);

                MenuItem externalViewer = new MenuItem("Open in External Viewer");
                final ExternalViewerAction externalViewerAction = new ExternalViewerAction("Open in External Viewer", new FileNode(getFile().getAbstractFile()));

                externalViewer.setDisable(externalViewerAction.isEnabled() == false);
                externalViewer.setOnAction((ActionEvent t) -> {
                    SwingUtilities.invokeLater(() -> {
                        externalViewerAction.actionPerformed(null);
                    });
                });
                menuItems.add(externalViewer);
View Full Code Here

        tagSelectedMenuButton.setGraphic(new ImageView(DrawableAttribute.TAGS.getIcon()));
        tagSelectedMenuButton.showingProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> {
            if (t1) {
                ArrayList<MenuItem> selTagMenues = new ArrayList<>();
                for (final TagName tn : TagUtils.getNonCategoryTagNames()) {
                    MenuItem menuItem = TagUtils.createSelTagMenuItem(tn, tagSelectedMenuButton);
                    selTagMenues.add(menuItem);
                }
                tagSelectedMenuButton.getItems().setAll(selTagMenues);
            }
        });

        catSelectedMenuButton.setOnAction(Category.FIVE.createSelCatMenuItem(catSelectedMenuButton).getOnAction());
        catSelectedMenuButton.setText(Category.FIVE.getDisplayName());
        catSelectedMenuButton.setGraphic(new ImageView(DrawableAttribute.CATEGORY.getIcon()));
        catSelectedMenuButton.showingProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> {
            if (t1) {
                ArrayList<MenuItem> categoryMenues = new ArrayList<>();
                for (final Category cat : Category.values()) {
                    MenuItem menuItem = cat.createSelCatMenuItem(catSelectedMenuButton);
                    categoryMenues.add(menuItem);
                }
                catSelectedMenuButton.getItems().setAll(categoryMenues);
            }
        });
View Full Code Here

        }
        return StringUtils.defaultIfBlank(groupName, DrawableGroup.UNKNOWN) + " -- " + hashHitCount + " hash set hits / " + size + " files";
    }

    private MenuItem createGrpCatMenuItem(final Category cat) {
        final MenuItem menuItem = new MenuItem(cat.getDisplayName(), new ImageView(DrawableAttribute.CATEGORY.getIcon()));
        menuItem.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                selectAllFiles();
                new CategorizeAction().addTag(cat.getTagName(), "");
View Full Code Here

        histogramBox.setStyle("   -fx-padding: 0,0.5em,0,.5em; ");

        zoomMenuButton.getItems().clear();
        for (ZoomRanges b : ZoomRanges.values()) {

            MenuItem menuItem = new MenuItem(b.getDisplayName());
            menuItem.setOnAction((event) -> {
                if (b != ZoomRanges.ALL) {
                    controller.pushPeriod(b.getPeriod());
                } else {
                    controller.showFullRange();
                }
View Full Code Here

        //use row factory as hook to attach context menus to.
        filterTreeTable.setRowFactory((TreeTableView<Filter> param) -> {
            final TreeTableRow<Filter> row = new TreeTableRow<>();

            MenuItem all = new MenuItem("all");
            all.setOnAction(e -> {
                row.getTreeItem().getParent().getChildren().forEach((TreeItem<Filter> t) -> {
                    t.getValue().setActive(Boolean.TRUE);
                });
            });
            MenuItem none = new MenuItem("none");
            none.setOnAction(e -> {
                row.getTreeItem().getParent().getChildren().forEach((TreeItem<Filter> t) -> {
                    t.getValue().setActive(Boolean.FALSE);
                });
            });

            MenuItem only = new MenuItem("only");
            only.setOnAction(e -> {
                row.getTreeItem().getParent().getChildren().forEach((TreeItem<Filter> t) -> {
                    if (t == row.getTreeItem()) {
                        t.getValue().setActive(Boolean.TRUE);
                    } else {
                        t.getValue().setActive(Boolean.FALSE);
                    }
                });
            });
            MenuItem others = new MenuItem("others");
            others.setOnAction(e -> {
                row.getTreeItem().getParent().getChildren().forEach((TreeItem<Filter> t) -> {
                    if (t == row.getTreeItem()) {
                        t.getValue().setActive(Boolean.FALSE);
                    } else {
                        t.getValue().setActive(Boolean.TRUE);
View Full Code Here

TOP

Related Classes of javafx.scene.control.MenuItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.