当前位置: 首页>>代码示例>>Java>>正文


Java ContextMenu.show方法代码示例

本文整理汇总了Java中javafx.scene.control.ContextMenu.show方法的典型用法代码示例。如果您正苦于以下问题:Java ContextMenu.show方法的具体用法?Java ContextMenu.show怎么用?Java ContextMenu.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.ContextMenu的用法示例。


在下文中一共展示了ContextMenu.show方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openOpenNewTabMenu

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
public void openOpenNewTabMenu() {
    if (root.getSelectionModel().getSelectedItem() != null) {
        Tab selectedFile = root.getSelectionModel().getSelectedItem();
        ContextMenu contextMenu = new ContextMenu();
        for (EditorView ev : editorController.getRegisteredEditors()) {
            MenuItem item = new MenuItem(ev.getDisplayName());
            item.setOnAction(event -> {
                openNewEditor(selectedFile, ev);
            });
            contextMenu.getItems().add(item);
        }
        contextMenu.setOnHidden(event -> {
            isMenuOpen = false;
        });
        Point p = MouseInfo.getPointerInfo().getLocation();
        contextMenu.show(root.getScene().getWindow(), p.x, p.y);
    }
}
 
开发者ID:helios-decompiler,项目名称:standalone-app,代码行数:19,代码来源:AllFilesViewerController.java

示例2: getFileContextMenu

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
public static void getFileContextMenu(HBox fileIcon, String fileName, MouseEvent e, ClientObject client) {
    ContextMenu cm = new ContextMenu();
    MenuItem sb1 = new MenuItem("Delete File");
    MenuItem sb2 = new MenuItem("Download File");
    sb2.setOnAction(event -> {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        directoryChooser.setTitle("Select download location");
        File selectedDirectory =
                directoryChooser.showDialog(Maus.getPrimaryStage());
        FileContextMenu.selectedDirectory = selectedDirectory.getAbsolutePath();
        try {
            client.clientCommunicate("DOWNLOAD");
            client.clientCommunicate(fileName);
        } catch (IOException e1) {
            Logger.log(Level.ERROR, e1.toString());
        }
    });
    cm.getItems().addAll(sb1, sb2);
    cm.show(fileIcon, e.getScreenX(), e.getScreenY());
}
 
开发者ID:Ghosts,项目名称:Maus,代码行数:21,代码来源:FileContextMenu.java

示例3: createPaneContextMenu

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
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());
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:13,代码来源:WidgetPaneController.java

示例4: getDirectoryMenu

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
public static void getDirectoryMenu(HBox fileIcon, String fileName, MouseEvent e, ClientObject client) {
    ContextMenu cm = new ContextMenu();
    MenuItem sb2 = new MenuItem("Open Folder");
    sb2.setOnAction(event -> {
        try {
            client.clientCommunicate("CHNGDIR");
            DataOutputStream dos = new DataOutputStream(client.getClient().getOutputStream());
            dos.writeUTF(fileName);
        } catch (IOException e1) {
            Logger.log(Level.ERROR, e1.toString());
        }
    });
    cm.getItems().addAll(sb2);
    cm.show(fileIcon, e.getScreenX(), e.getScreenY());
}
 
开发者ID:Ghosts,项目名称:Maus,代码行数:16,代码来源:FileContextMenu.java

示例5: click

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
@Override
public void click(final MouseEvent event, final MapTile tile, final Node rootNode, final MapEditor map) {
	if (!dragging) {
		changedPoints.clear();
	}
	//TODO Pick tiles better
	if (event.getButton() == MouseButton.PRIMARY) {
		map.startEdit();
		int x = convertCoord(event.getX());
		int y = convertCoord(event.getY());
		map.setTile(x, y, null);
		changedPoints.add(new Point(x, y));
	} else if (event.getButton() == MouseButton.SECONDARY && !dragging) {

		MenuItem clearAllMenuItem = new MenuItem("Erase All");
		clearAllMenuItem.setOnAction(event1 -> {
			map.startEdit();
			for (int x = 0; x < MapEditor.SIZE; x++) {
				for (int y = 0; y < MapEditor.SIZE; y++) {
					map.setTile(x, y, null);
					changedPoints.add(new Point(x, y));
				}
			}
			map.finishEdit("Eraser");
		});

		MenuItem cancelItem = new MenuItem("Cancel");

		ContextMenu contextMenu = new ContextMenu(clearAllMenuItem, new SeparatorMenuItem(), cancelItem);
		contextMenu.setAutoHide(true);
		contextMenu.setHideOnEscape(true);

		cancelItem.setOnAction(event1 -> contextMenu.hide());

		contextMenu.show(rootNode, event.getScreenX(), event.getScreenY());

	}
}
 
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA-Map-Editor,代码行数:39,代码来源:EraserTool.java

示例6: showContextMenu

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
private void showContextMenu(final TwitchChannel channel, final double xPos, final double yPos) {
    final ContextMenu contextMenu = new ContextMenu();
    final MenuItem startStream = new MenuItem("Start Stream");
    startStream.setOnAction(eventStartContext -> BrowserCore.getInstance().startStream(channel.getName().get()));
    final MenuItem addToList = new MenuItem("Add Stream To Favourites");
    final IService twitchService = Settings.getInstance().getTwitchService();
    addToList
            .setOnAction(eventAddContext -> LsGuiUtils.addChannelToService(channel.getName().get(), twitchService));
    contextMenu.getItems().add(startStream);
    contextMenu.getItems().add(addToList);
    contextMenu.show(this.getScene().getWindow(), xPos, yPos);
}
 
开发者ID:westerwave,项目名称:livestreamer_twitch_gui,代码行数:13,代码来源:TwitchItemPane.java

示例7: showContextMenu

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
private void showContextMenu(ContextMenuEvent e) {
    ContextMenu menu = view.getContextMenu();
    double xOffset = view.getContextMenuXOffset();
    double yOffset = view.getContextMenuYOffset();

    menu.show(view, e.getScreenX() + xOffset, e.getScreenY() + yOffset);
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:8,代码来源:GenericStyledAreaBehavior.java

示例8: handle

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
@Override
        public void handle(final MouseEvent event) {
            // On right click
            if (event.getButton() == MouseButton.SECONDARY) {

                // Create a context menu
                final ContextMenu contextMenu = new ContextMenu();

                // Entry to delete a plug
                final MenuItem deleteMenu = new MenuItem(null, new Label("Delete"));
                deleteMenu.setOnAction(e -> {
                    CoreController.getConnectionManager().deleteCable(cable);
                });

                // Entry to change the color of a plug
                final ColorPicker colorPicker = new ColorPicker();
                colorPicker.setValue(cable.getColor());
                colorPicker.getStyleClass().add("button");
                colorPicker.setStyle("-fx-background-color: transparent;");

                final MenuItem colorMenu = new MenuItem(null, colorPicker);
                colorMenu.setOnAction(e -> cable.setColor(colorPicker.getValue()));

                // Show the context menu
                contextMenu.getItems().addAll(deleteMenu, colorMenu);
                contextMenu.show(cable , event.getScreenX(), event.getScreenY());

                event.consume();
            }
            // FIXME: when managed inside the curvecable, the moving of a cable does not work properly, it creates a new cable after reconnection
            // because of the connection manager which has finished the first connection, so no more current cable and no more cable attached to the plug yet !!!
//            if (event.getButton() == MouseButton.PRIMARY) {
//                if (plugState == PlugState.PLUGGED) {
//                    Point2D clickPoint = new Point2D(event.getSceneX(), event.getSceneY());
//                    Point2D inputPoint = computeCoordinates(inputPlug);
//                    Point2D outputPoint = computeCoordinates(outputPlug);
//                    if (inputPoint.distance(clickPoint) < outputPoint.distance(clickPoint)) {
//                        disconnectInputPlug();
//                    } else {
//                        disconnectOutputPlug();
//                    }
//                    // Then call the connectionManager to give this plug
//                    //CoreController.getConnectionManager().setCurrentCable((CurveCable) event.getSource());
//                    event.consume();
//                }
//            }
        }
 
开发者ID:StephaneMangin,项目名称:Synth,代码行数:48,代码来源:CurveCable.java


注:本文中的javafx.scene.control.ContextMenu.show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。