Search in sources :

Example 56 with ContextMenu

use of javafx.scene.control.ContextMenu 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 57 with ContextMenu

use of javafx.scene.control.ContextMenu 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 58 with ContextMenu

use of javafx.scene.control.ContextMenu 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)

Example 59 with ContextMenu

use of javafx.scene.control.ContextMenu in project uPMT by coco35700.

the class MomentContextMenu method init.

public void init(Stage stage) {
    HBox root = new HBox();
    root.setPadding(new Insets(5));
    root.setSpacing(5);
    // Create ContextMenu
    contextMenu = new ContextMenu();
    MenuItem item1 = new MenuItem("Menu Item 1");
    item1.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
        // clique sur item1
        }
    });
    MenuItem item2 = new MenuItem("Menu Item 2");
    item2.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
        // clique sur item2
        }
    });
    Button item3 = new Button("Bt");
// Add MenuItem to ContextMenu
// contextMenu.getItems().addAll(item1, item2, item3);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) ActionEvent(javafx.event.ActionEvent) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem)

Example 60 with ContextMenu

use of javafx.scene.control.ContextMenu in project jfreechart-fx by jfree.

the class ChartViewer method createContextMenu.

/**
 * Creates the context menu.
 *
 * @return The context menu.
 */
private ContextMenu createContextMenu() {
    final ContextMenu menu = new ContextMenu();
    menu.setAutoHide(true);
    Menu export = new Menu("Export As");
    MenuItem pngItem = new MenuItem("PNG...");
    pngItem.setOnAction(e -> handleExportToPNG());
    export.getItems().add(pngItem);
    MenuItem jpegItem = new MenuItem("JPEG...");
    jpegItem.setOnAction(e -> handleExportToJPEG());
    export.getItems().add(jpegItem);
    if (ExportUtils.isOrsonPDFAvailable()) {
        MenuItem pdfItem = new MenuItem("PDF...");
        pdfItem.setOnAction(e -> handleExportToPDF());
        export.getItems().add(pdfItem);
    }
    if (ExportUtils.isJFreeSVGAvailable()) {
        MenuItem svgItem = new MenuItem("SVG...");
        svgItem.setOnAction(e -> handleExportToSVG());
        export.getItems().add(svgItem);
    }
    menu.getItems().add(export);
    return menu;
}
Also used : ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) Menu(javafx.scene.control.Menu) ContextMenu(javafx.scene.control.ContextMenu)

Aggregations

ContextMenu (javafx.scene.control.ContextMenu)81 MenuItem (javafx.scene.control.MenuItem)69 ActionEvent (javafx.event.ActionEvent)21 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)20 Menu (javafx.scene.control.Menu)18 Label (javafx.scene.control.Label)15 List (java.util.List)13 Collectors (java.util.stream.Collectors)13 File (java.io.File)12 VBox (javafx.scene.layout.VBox)11 ObservableList (javafx.collections.ObservableList)9 ArrayList (java.util.ArrayList)8 EventHandler (javafx.event.EventHandler)8 FXCollections (javafx.collections.FXCollections)7 Optional (java.util.Optional)6 Node (javafx.scene.Node)6 Scene (javafx.scene.Scene)6 Text (javafx.scene.text.Text)6 IOException (java.io.IOException)5 Arrays (java.util.Arrays)5