@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(); }
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); }
@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; }
private MenuItem createMenuItem(JSONObject testJSON, boolean selectSave) { MenuItem item = new MenuItem(testJSON.getString("name") + " (" + testJSON.get("run-on") + ")"); item.setOnAction((e) -> { errorMsgLabel.setVisible(false); errorMsgLabel.setText(null); Test test = createTest(testJSON); if (errorMsgLabel.getText() != null) { errorMsgLabel.setVisible(true); } console.clear(); progressBar.reset(test.countTestCases()); status.setText("Ready"); TestTreeItem root = new TestTreeItem(test, this); testTree.setRoot(root); setState(root, testJSON); root.setExpanded(true); runReportDir = new File(reportDir, testJSON.getString("runReportDir")); }); return item; }
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; }
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); }
@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); }
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; }
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); }
@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)); }
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); } }
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); } }
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); }
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); }
@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); } }); }
@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; } }
@Override @FXThread public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) { items.add(new CreateVehicleWheelAction(nodeTree, this)); super.fillContextMenu(nodeTree, items); }
/** * 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; }
@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)); }
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; }
private Menu getHelpMenu() { Menu result = new Menu("Help"); MenuItem aboutItem = new MenuItem("About Titanium"); result.getItems().addAll(aboutItem); return result; }
@Override @FXThread public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) { super.fillContextMenu(nodeTree, items); items.add(new RemoveVehicleWheelAction(nodeTree, this)); }
@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)); } }
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(); } } }
@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); } }
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; }
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); } }
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); } }
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()); }
public ContextMenu getDefaultMenu() { ContextMenu menu = new ContextMenu(); List<MenuItem> items = new ArrayList<>(); items.add(addChannel); menu.getItems().addAll(items); return menu; }
/** * 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)); } }); } }
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; }
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; }
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; }
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)); }
private ContextMenu createTabContextMenu() { ContextMenu contextMenu = new ContextMenu(); MenuItem setNameItem = new MenuItem("Rename"); setNameItem.setOnAction(this::onTabSetName); contextMenu.getItems().add(setNameItem); return contextMenu; }
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; }
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; }
@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()]); }
/** * 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; }