Java Code Examples for javafx.scene.control.MenuItem

The following are top voted examples for showing how to use javafx.scene.control.MenuItem. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Vokabeltrainer   File: Main.java   View source code 7 votes vote down vote up
@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();
	}
 
Example 2
Project: cayenne-modeler   File: ObjectEntityTreeItem.java   View source code 6 votes vote down vote up
@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;
}
 
Example 3
Project: vars-annotation   File: AssocButtonFactory.java   View source code 6 votes vote down vote up
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;

    }
 
Example 4
Project: marathonv5   File: ACEEditor.java   View source code 6 votes vote down vote up
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);
}
 
Example 5
Project: jmonkeybuilder   File: SpatialTreeNode.java   View source code 6 votes vote down vote up
@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);
}
 
Example 6
Project: marathonv5   File: RFXMenuItem.java   View source code 6 votes vote down vote up
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;
}
 
Example 7
Project: CalendarFX   File: CalendarSelectorSkin.java   View source code 6 votes vote down vote up
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);
}
 
Example 8
Project: CalendarFX   File: GoogleEntryAttendeesView.java   View source code 6 votes vote down vote up
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()));
}
 
Example 9
Project: marathonv5   File: RFXMenuItemTest.java   View source code 6 votes vote down vote up
@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));
}
 
Example 10
Project: HotaruFX   File: EditorController.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 11
Project: BatpackJava   File: batteryMonitorLayoutController.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 12
Project: ClassViewer   File: TextPaneMenu.java   View source code 6 votes vote down vote up
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);
}
 
Example 13
Project: ClassViewer   File: AsciiPaneMenu.java   View source code 6 votes vote down vote up
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);
}
 
Example 14
Project: Cognizant-Intelligent-Test-Scripter   File: HelpBrowser.java   View source code 6 votes vote down vote up
@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);
        }
    });

}
 
Example 15
Project: Goliath-Overclocking-Utility-FX   File: ThemesMenu.java   View source code 6 votes vote down vote up
@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;   
    }
}
 
Example 16
Project: Goliath-Overclocking-Utility-FX   File: TabsMenu.java   View source code 6 votes vote down vote up
public TabsMenu(TabPane tabPane)
{
    super("Tabs");
    
    tabPaneToAddTo = tabPane;
    tabs = tabPane.getTabs().toArray(new Tab[tabPane.getTabs().size()]);
    
    handler = new MenuHandler(tabs);
    
    for(int i = 0; i < tabs.length; i++)
    {
        MenuItem tmp = new MenuItem(tabs[i].getText());
        tmp.setOnAction(handler);
        super.getItems().add(tmp);
    }
    tabPaneToAddTo.getTabs().remove(3, 5);
}
 
Example 17
Project: jmonkeybuilder   File: VehicleControlTreeNode.java   View source code 5 votes vote down vote up
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree,
                            @NotNull final ObservableList<MenuItem> items) {

    items.add(new CreateVehicleWheelAction(nodeTree, this));

    super.fillContextMenu(nodeTree, items);
}
 
Example 18
Project: shuffleboard   File: ActionList.java   View source code 5 votes vote down vote up
/**
 * Add an action with an associated graphic, such as a checkmark or icon.
 */
public ActionList addAction(String name, Node graphic, Runnable r) {
  actions.add(() -> {
    MenuItem item = FxUtils.menuItem(name, _e -> r.run());
    item.setGraphic(graphic);
    return item;
  });
  return this;
}
 
Example 19
Project: jmonkeybuilder   File: SceneNodeTreeNode.java   View source code 5 votes vote down vote up
@Override
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) {
    if (!(nodeTree instanceof ModelNodeTree)) return;

    final Menu createMenu = createCreationMenu(nodeTree);

    items.add(createMenu);
    items.add(new RenameNodeAction(nodeTree, this));
}
 
Example 20
Project: WebPLP   File: PLPToolMenuBarPanel.java   View source code 5 votes vote down vote up
private Menu createViewMenu()
{
	Menu viewMenu = new Menu("View");
	
	MenuItem itemClearOutput = new MenuItem("Clear Output Pane");
	itemClearOutput.setAccelerator(new KeyCodeCombination(KeyCode.D,
			KeyCombination.CONTROL_DOWN));
	itemClearOutput.setOnAction((e) -> controller.clearConsole());
	
	viewMenu.getItems().addAll(itemClearOutput);
	return viewMenu;
}
 
Example 21
Project: titanium   File: MainPane.java   View source code 5 votes vote down vote up
private Menu getHelpMenu() {
	Menu result = new Menu("Help");
	MenuItem aboutItem = new MenuItem("About Titanium");

	result.getItems().addAll(aboutItem);

	return result;
}
 
Example 22
Project: jmonkeybuilder   File: VehicleWheelTreeNode.java   View source code 5 votes vote down vote up
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree,
                            @NotNull final ObservableList<MenuItem> items) {
    super.fillContextMenu(nodeTree, items);
    items.add(new RemoveVehicleWheelAction(nodeTree, this));
}
 
Example 23
Project: jmonkeybuilder   File: SceneLayerTreeNode.java   View source code 5 votes vote down vote up
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) {
    super.fillContextMenu(nodeTree, items);

    final SceneLayer layer = getElement();

    if (!layer.isBuiltIn()) {
        items.add(new RenameNodeAction(nodeTree, this));
        items.add(new RemoveSceneLayerAction(nodeTree, this));
    }
}
 
Example 24
Project: JavaFX-EX   File: RecentFileMenuSupport.java   View source code 5 votes vote down vote up
public File getLastFile() {
  if (recents.size() == 0) {
    return new File(".");
  } else {
    Pair<File, MenuItem> pair = recents.remove(recents.size() - 1);
    File file = pair.getKey();
    if (Files.exists(file.toPath())) {
      return file;
    } else {
      recents.remove(pair);
      return getLastFile();
    }
  }
}
 
Example 25
Project: tenhou-visualizer   File: InfoSchemaTableRow.java   View source code 5 votes vote down vote up
@Override
protected void updateItem(InfoSchema item, boolean empty) {
    super.updateItem(item, empty);
    if (empty) {
        this.setContextMenu(null);
    } else {
        ContextMenu contextMenu = new ContextMenu();
        if (!this.service.isDownloaded(item)) {
            MenuItem downloadMjlog = new MenuItem("牌譜をデータベースに追加する");
            downloadMjlog.setOnAction(e -> this.controller.downloadMjlog(null));
            contextMenu.getItems().add(downloadMjlog);
        } else {
            MenuItem removeMjlog = new MenuItem("牌譜をデータベースから削除する");
            removeMjlog.setOnAction(e -> this.controller.removeMjlog(null));
            contextMenu.getItems().add(removeMjlog);
        }
        contextMenu.getItems().add(new SeparatorMenuItem());
        MenuItem filterWithFirst = new MenuItem("「" + item.getFirst() + "」で検索");
        filterWithFirst.setOnAction(e -> updateFilter(item.getFirst()));
        MenuItem filterWithSecond = new MenuItem("「 " + item.getSecond() + "」で検索");
        filterWithSecond.setOnAction(e -> updateFilter(item.getSecond()));
        MenuItem filterWithThird = new MenuItem("「 " + item.getThird() + "」で検索");
        filterWithThird.setOnAction(e -> updateFilter(item.getThird()));
        contextMenu.getItems().addAll(filterWithFirst, filterWithSecond, filterWithThird);
        if (item.getFourth() != null) {
            MenuItem filterWithFourth = new MenuItem("「 " + item.getFourth() + "」で検索");
            filterWithFourth.setOnAction(e -> updateFilter(item.getFourth()));
            contextMenu.getItems().add(filterWithFourth);
        }
        this.setContextMenu(contextMenu);
    }
}
 
Example 26
Project: Squid   File: SpotManagerController.java   View source code 5 votes vote down vote up
private ContextMenu createRefMatSpotsViewContextMenu() {
    ContextMenu contextMenu = new ContextMenu();
    MenuItem menuItem = new MenuItem("Clear list.");
    menuItem.setOnAction((evt) -> {
        squidProject.updateFilterForRefMatSpotNames("");
        updateReferenceMaterialsList(true);
    });
    contextMenu.getItems().add(menuItem);
    return contextMenu;
}
 
Example 27
Project: LIRE-Lab   File: MenuBarController.java   View source code 5 votes vote down vote up
private void setupFileMenu() {
    List<Command<Void>> commands = applicationCommands.getFileMenuCommands();
    for (Command<Void> command : commands) {
        MenuItem menuItem = commandTriggerFactory.createMenuItem(command, () -> null);
        menuItem.setId(command.getNodeId());
        fileMenu.getItems().add(menuItem);
    }
}
 
Example 28
Project: Squid   File: SquidUIController.java   View source code 5 votes vote down vote up
private void buildTaskLibraryMenu() {
    selectSquid3TaskFromLibraryMenu.setDisable(false);

    selectSquid3TaskFromLibraryMenu.getItems().clear();
    Map< String, TaskInterface> taskLibrary = squidProject.getTaskLibrary();
    for (Map.Entry< String, TaskInterface> entry : taskLibrary.entrySet()) {
        MenuItem menuItem = new MenuItem(entry.getKey());
        menuItem.setOnAction((ActionEvent t) -> {
            // get a new library
            squidProject.loadAndInitializeLibraryTask(squidProject.getTaskLibrary().get(menuItem.getText()));
            launchTaskManager();
        });
        selectSquid3TaskFromLibraryMenu.getItems().add(menuItem);
    }
}
 
Example 29
Project: shuffleboard   File: WidgetPaneController.java   View source code 5 votes vote down vote up
private void createPaneContextMenu(ContextMenuEvent e) {
  MenuItem clear = FxUtils.menuItem("Clear", __ -> {
    List<Tile> tiles = new ArrayList<>(pane.getTiles());
    tiles.stream()
        .map((Function<Tile, Component>) pane::removeTile)
        .flatMap(Component::allComponents)
        .flatMap(TypeUtils.castStream(Sourced.class))
        .forEach(Sourced::removeAllSources);
  });
  ContextMenu contextMenu = new ContextMenu(clear);
  contextMenu.show(pane.getScene().getWindow(), e.getScreenX(), e.getScreenY());
}
 
Example 30
Project: bubuirc   File: TreeContextMenuPane.java   View source code 5 votes vote down vote up
public ContextMenu getDefaultMenu() {
	ContextMenu menu = new ContextMenu();
	List<MenuItem> items = new ArrayList<>();
	items.add(addChannel);
	menu.getItems().addAll(items);
	return menu;
}
 
Example 31
Project: stvs   File: TimingDiagramController.java   View source code 5 votes vote down vote up
/**
 * Create mouse events and context menu entries.
 */
private void initCommon() {
  view.setDurations(concreteSpec.getDurations());
  // view.getyAxis().layoutBoundsProperty().addListener(change -> updateAxisExternalPosition());
  view.setOnMouseClicked(this::onMouseClicked);
  MenuItem xpositiveZoomItem = new MenuItem("Zoom X+");
  xpositiveZoomItem.setOnAction(this::onXPositiveZoom);
  MenuItem xnegativeZoomItem = new MenuItem("Zoom X-");
  xnegativeZoomItem.setOnAction(this::onXNegativeZoom);
  view.getContextMenu().getItems().setAll(xpositiveZoomItem, xnegativeZoomItem);
  ObservableList<Rectangle> cycleSelectionRectangles = view.getCycleSelectionRectangles();
  for (int i = 0; i < cycleSelectionRectangles.size(); i++) {
    Rectangle cycleSelectionRectangle = cycleSelectionRectangles.get(i);
    int finalCycleIndex = i;
    cycleSelectionRectangle.setOnMouseEntered(event -> {
      if (activated.get()) {
        cycleSelectionRectangle.setOpacity(1);
        selection.setRow(concreteSpec.cycleToRowNumber(finalCycleIndex));
        selection.setColumn(ioVariable.getName());
      }
    });
    cycleSelectionRectangle.setOnMouseExited(event -> {
      if (activated.get()) {
        cycleSelectionRectangle.setOpacity(0);
        selection.clear();
      }
    });
    cycleSelectionRectangle.setOnMouseClicked(event -> {
      if (event.getButton() == MouseButton.PRIMARY) {
        selection.fireClickEvent(ioVariable.getName(),
            concreteSpec.cycleToRowNumber(finalCycleIndex));
      }
    });
  }
}
 
Example 32
Project: fx-media-tags   File: FxMediaTags.java   View source code 5 votes vote down vote up
private MenuItem createMenuDelete() {
	final MenuItem menuDelete = new MenuItem("Delete");
	menuDelete.setOnAction(event -> {
		final MetaTagModel metaTagModel = TAGS_TABLE.getSelectionModel().getSelectedItem();
		if (null != metaTagModel) {
			if (null != MODEL.getOnDeleteTag()) {
				MODEL.getOnDeleteTag().accept(metaTagModel);
			}
			MODEL.tagsProperty().remove(metaTagModel);
		}
	});
	return menuDelete;
}
 
Example 33
Project: CalendarFX   File: AgendaView.java   View source code 5 votes vote down vote up
private ContextMenu buildContextMenu() {
    ContextMenu menu = new ContextMenu();
    Menu lookBackMenu = new Menu(Messages.getString("AgendaView.MENU_ITEM_LOOK_BACK")); //$NON-NLS-1$
    Menu lookAheadMenu = new Menu(Messages.getString("AgendaView.MENU_ITEM_LOOK_AHEAD")); //$NON-NLS-1$

    String format = Messages.getString("AgendaView.MENU_ITEM_DAYS"); //$NON-NLS-1$

    MenuItem lookBack0 = new MenuItem(MessageFormat.format(format, 0));
    MenuItem lookBack10 = new MenuItem(MessageFormat.format(format, 10));
    MenuItem lookBack20 = new MenuItem(MessageFormat.format(format, 20));
    MenuItem lookBack30 = new MenuItem(MessageFormat.format(format, 30));
    MenuItem lookAhead0 = new MenuItem(MessageFormat.format(format, 0));
    MenuItem lookAhead10 = new MenuItem(MessageFormat.format(format, 10));
    MenuItem lookAhead20 = new MenuItem(MessageFormat.format(format, 20));
    MenuItem lookAhead30 = new MenuItem(MessageFormat.format(format, 30));
    lookBackMenu.getItems().addAll(lookBack0, lookBack10, lookBack20, lookBack30);
    lookAheadMenu.getItems().addAll(lookAhead0, lookAhead10, lookAhead20, lookAhead30);
    menu.getItems().addAll(lookBackMenu, lookAheadMenu);

    lookBack0.setOnAction(evt -> setLookBackPeriodInDays(0));
    lookBack10.setOnAction(evt -> setLookBackPeriodInDays(10));
    lookBack20.setOnAction(evt -> setLookBackPeriodInDays(20));
    lookBack30.setOnAction(evt -> setLookBackPeriodInDays(30));

    lookAhead0.setOnAction(evt -> setLookAheadPeriodInDays(0));
    lookAhead10.setOnAction(evt -> setLookAheadPeriodInDays(10));
    lookAhead20.setOnAction(evt -> setLookAheadPeriodInDays(20));
    lookAhead30.setOnAction(evt -> setLookAheadPeriodInDays(30));

    return menu;
}
 
Example 34
Project: fx-media-tags   File: FxMediaTags.java   View source code 5 votes vote down vote up
private ContextMenu createContextMenu() {
	final ContextMenu contextMenu = new ContextMenu();
	final ObservableList<MenuItem> menuItems = contextMenu.getItems();
	menuItems.add(createMenuAdd());
	menuItems.add(createMenuDelete());
	menuItems.add(createMenuRename());
	menuItems.add(new SeparatorMenuItem());
	menuItems.add(new MenuItem("Cancel"));
	return contextMenu;
}
 
Example 35
Project: JavaFX-EX   File: RecentFileMenuSupport.java   View source code 5 votes vote down vote up
public void setLastFile(File file) {
  if (file == null) {
    return;
  }
  List<Pair<File, MenuItem>> collect = recents.stream().filter(p -> p.getKey().equals(file))
      .collect(Collectors.toList());
  recents.removeAll(collect);
  recents.add(getRecentMenuItemPair(file));
}
 
Example 36
Project: stvs   File: SpecificationsPaneController.java   View source code 5 votes vote down vote up
private ContextMenu createTabContextMenu() {
  ContextMenu contextMenu = new ContextMenu();
  MenuItem setNameItem = new MenuItem("Rename");
  setNameItem.setOnAction(this::onTabSetName);
  contextMenu.getItems().add(setNameItem);
  return contextMenu;
}
 
Example 37
Project: marathonv5   File: ProjectSelection.java   View source code 5 votes vote down vote up
private List<MenuItem> getAvailableFrameworks() {
    List<MenuItem> items = new ArrayList<>();
    for (List<String> framework : frameworks) {
        items.add(getFrameworkMenuItem(framework.get(0), framework.get(1)));
    }
    return items;
}
 
Example 38
Project: marathonv5   File: ProjectSelection.java   View source code 5 votes vote down vote up
public MenuItem getFrameworkMenuItem(String name, final String framework) {
    MenuItem projectMenuItem = new MenuItem(name);
    projectMenuItem.addEventHandler(ActionEvent.ACTION, (e) -> {
        System.setProperty(Constants.PROP_PROJECT_FRAMEWORK, framework);
        onNew();
    });
    return projectMenuItem;
}
 
Example 39
Project: marathonv5   File: FolderResource.java   View source code 5 votes vote down vote up
@Override public MenuItem[] getUnhideMenuItem() {
    return hiddenFiles.stream().map((file) -> {
        MenuItem menuItem = new MenuItem(file, new ImageView());
        menuItem.setOnAction((event) -> hiddenFiles.remove(file));
        return menuItem;
    }).collect(Collectors.toList()).toArray(new MenuItem[hiddenFiles.size()]);
}
 
Example 40
Project: jfreechart-fx   File: ChartViewer.java   View source code 5 votes vote down vote up
/**
 * 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;
}