Search in sources :

Example 86 with MenuItem

use of javafx.scene.control.MenuItem in project Gargoyle by callakrsos.

the class MacroSqlComposite method post.

@FxPostInitialize
public void post() {
    MenuItem menuAddItem = new MenuItem("Add");
    menuAddItem.setAccelerator(new KeyCodeCombination(KeyCode.INSERT, KeyCharacterCombination.CONTROL_DOWN));
    menuAddItem.setOnAction(e -> {
        addOnAction();
    });
    MenuItem menuDeleteItem = new MenuItem("Delete");
    menuDeleteItem.setAccelerator(new KeyCodeCombination(KeyCode.DELETE, KeyCharacterCombination.CONTROL_DOWN));
    menuDeleteItem.setOnAction(e -> {
        addOnAction();
    });
    tvFavorite.setContextMenu(new ContextMenu(menuAddItem, menuDeleteItem));
    borContent.setCenter(new MacroControl(connectionSupplier, initText));
    MacroFavorTreeItemCreator macroFavorTreeItem = new MacroFavorTreeItemCreator(connectionSupplier);
    MacroItemVO f = new MacroItemVO();
    tvFavorite.setRoot(macroFavorTreeItem.createRoot(f));
    tvFavorite.setShowRoot(false);
}
Also used : MenuItem(javafx.scene.control.MenuItem) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) ContextMenu(javafx.scene.control.ContextMenu) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)

Example 87 with MenuItem

use of javafx.scene.control.MenuItem in project trex-stateless-gui by cisco-system-traffic-generator.

the class ChartContainer method handleContextMenuAction.

private void handleContextMenuAction(ActionEvent event) {
    MenuItem source = (MenuItem) event.getSource();
    chartType.set(source.getText());
    chart.setActive(true);
}
Also used : MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem)

Example 88 with MenuItem

use of javafx.scene.control.MenuItem in project on-track by michaelplazek.

the class TrackModelController method toggleSelectedFailures.

/**
 * Toggle the failures.
 * @param event pass event.
 */
public void toggleSelectedFailures(ActionEvent event) {
    Button btn = (Button) event.getSource();
    for (MenuItem item : failures.getItems()) {
        if (CheckMenuItem.class.isInstance(item) && CheckMenuItem.class.cast(item).isSelected()) {
            if (item.getId().equals(powerFailureSelect.getId())) {
                if (btn.getId().equals(start.getId())) {
                    blocks[(int) blockNumber.getValue() - 1].setPowerStatus(true);
                    powerStatus.setFill(Color.GREEN);
                } else if (btn.getId().equals(end.getId())) {
                    blocks[(int) blockNumber.getValue() - 1].setPowerStatus(false);
                    powerStatus.setFill(Color.WHITE);
                }
            } else if (item.getId().equals(railFailureSelect.getId())) {
                if (btn.getId().equals(start.getId())) {
                    blocks[(int) blockNumber.getValue() - 1].setBrokenRailStatus(true);
                    railStatus.setFill(Color.GREEN);
                } else if (btn.getId().equals(end.getId())) {
                    blocks[(int) blockNumber.getValue() - 1].setBrokenRailStatus(false);
                    railStatus.setFill(Color.WHITE);
                }
            } else if (item.getId().equals(trackFailureSelect.getId())) {
                if (btn.getId().equals(start.getId())) {
                    blocks[(int) blockNumber.getValue() - 1].setTrackCircuitStatus(true);
                    circuitStatus.setFill(Color.GREEN);
                } else if (btn.getId().equals(end.getId())) {
                    blocks[(int) blockNumber.getValue() - 1].setTrackCircuitStatus(false);
                    circuitStatus.setFill(Color.WHITE);
                }
            }
        }
    }
}
Also used : CheckMenuItem(javafx.scene.control.CheckMenuItem) Button(javafx.scene.control.Button) MenuButton(javafx.scene.control.MenuButton) CheckMenuItem(javafx.scene.control.CheckMenuItem) MenuItem(javafx.scene.control.MenuItem)

Example 89 with MenuItem

use of javafx.scene.control.MenuItem in project blue by kunstmusik.

the class BSBEditPane method setupPopupMenus.

private void setupPopupMenus(BSBObjectEntry[] bsbObjectEntries) {
    popupMenu = new ContextMenu();
    EventHandler<ActionEvent> al = e -> {
        MenuItem m = (MenuItem) e.getSource();
        Class<? extends BSBObject> clazz = (Class<? extends BSBObject>) m.getUserData();
        try {
            BSBObject bsbObj = clazz.newInstance();
            bsbObj.setX(addX);
            bsbObj.setY(addY);
            currentBSBGroup.addBSBObject(bsbObj);
        } catch (InstantiationException | IllegalAccessException ex) {
            Exceptions.printStackTrace(ex);
        }
    };
    for (BSBObjectEntry entry : bsbObjectEntries) {
        MenuItem m = new MenuItem("Add " + entry.label);
        m.setUserData(entry.bsbObjectClass);
        m.setOnAction(al);
        popupMenu.getItems().add(m);
    }
    MenuItem paste = new MenuItem("Paste");
    paste.setOnAction(ae -> paste(addX, addY));
    paste.disableProperty().bind(Bindings.createBooleanBinding(() -> selection.copyBufferProperty().size() == 0, selection.copyBufferProperty()));
    popupMenu.getItems().addAll(new SeparatorMenuItem(), paste);
    nonEditPopupMenu = new ContextMenu();
    MenuItem randomize = new MenuItem("Randomize");
    randomize.setOnAction(ae -> {
        if (bsbInterface != null) {
            bsbInterface.getRootGroup().randomize();
        }
    });
    nonEditPopupMenu.getItems().add(randomize);
}
Also used : EventHandler(javafx.event.EventHandler) SetChangeListener(javafx.collections.SetChangeListener) FXCollections(javafx.collections.FXCollections) Bindings(javafx.beans.binding.Bindings) InvalidationListener(javafx.beans.InvalidationListener) HashSet(java.util.HashSet) BSBGroup(blue.orchestra.blueSynthBuilder.BSBGroup) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) Exceptions(org.openide.util.Exceptions) EditModeOnly(blue.orchestra.editor.blueSynthBuilder.EditModeOnly) BSBGraphicInterface(blue.orchestra.blueSynthBuilder.BSBGraphicInterface) BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) Pane(javafx.scene.layout.Pane) Color(javafx.scene.paint.Color) MenuItem(javafx.scene.control.MenuItem) GraphicsContext(javafx.scene.canvas.GraphicsContext) Collection(java.util.Collection) Node(javafx.scene.Node) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings) Set(java.util.Set) Canvas(javafx.scene.canvas.Canvas) Rectangle(javafx.scene.shape.Rectangle) KeyEvent(javafx.scene.input.KeyEvent) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Region(javafx.scene.layout.Region) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) ChangeListener(javafx.beans.value.ChangeListener) BSBObjectEntry(blue.orchestra.blueSynthBuilder.BSBObjectEntry) Bounds(javafx.geometry.Bounds) ActionEvent(javafx.event.ActionEvent) BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) BSBObjectEntry(blue.orchestra.blueSynthBuilder.BSBObjectEntry) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem)

Example 90 with MenuItem

use of javafx.scene.control.MenuItem in project kanonizo by kanonizo.

the class KanonizoFrame method addLibListeners.

private void addLibListeners() {
    ContextMenu menu = new ContextMenu();
    MenuItem addLib = new MenuItem();
    addLib.textProperty().set("Add Library");
    addLib.setOnAction((ActionEvent ev) -> {
        FileChooser fc = new FileChooser();
        fc.setInitialDirectory(fw.getRootFolder());
        fc.setSelectedExtensionFilter(new ExtensionFilter("Only jar files!", "jar"));
        List<File> jar = fc.showOpenMultipleDialog(KanonizoFxApplication.stage);
        if (jar != null) {
            for (File j : jar) {
                fw.addLibrary(j);
            }
        }
    });
    menu.getItems().add(addLib);
    libs.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
        if (ev.getButton().equals(MouseButton.SECONDARY)) {
            menu.show(libs, ev.getScreenX(), ev.getScreenY());
        } else if (menu.isShowing()) {
            menu.hide();
        }
    });
    GuiUtils.setDefaultListName(libs);
}
Also used : ActionEvent(javafx.event.ActionEvent) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) FileChooser(javafx.stage.FileChooser) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) File(java.io.File)

Aggregations

MenuItem (javafx.scene.control.MenuItem)136 ContextMenu (javafx.scene.control.ContextMenu)72 Menu (javafx.scene.control.Menu)41 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)41 ActionEvent (javafx.event.ActionEvent)30 File (java.io.File)23 VBox (javafx.scene.layout.VBox)21 ArrayList (java.util.ArrayList)20 List (java.util.List)20 Scene (javafx.scene.Scene)20 Label (javafx.scene.control.Label)19 Collectors (java.util.stream.Collectors)16 MenuBar (javafx.scene.control.MenuBar)15 ObservableList (javafx.collections.ObservableList)13 IOException (java.io.IOException)12 EventHandler (javafx.event.EventHandler)12 Button (javafx.scene.control.Button)12 ImageView (javafx.scene.image.ImageView)12 FXCollections (javafx.collections.FXCollections)11 KeyCodeCombination (javafx.scene.input.KeyCodeCombination)11