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


Java ContextMenu.setAutoHide方法代码示例

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


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

示例1: createContextMenu

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:32,代码来源:ChartViewer.java

示例2: 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

示例3: createStageMenu

import javafx.scene.control.ContextMenu; //导入方法依赖的package包/类
/**
 * Creates the context menu for the stage.
 */
private void createStageMenu()
{
	contextMenu = new ContextMenu();
	contextMenu.setAutoHide(true);
	contextMenu.setHideOnEscape(true);
	
	miIconify = new MenuItem("Minimize");
	miIconify.setGraphic(new FXImageRegion(new Image("/com/sibvisions/rad/ui/javafx/ext/scene/css/iconify_menu.png")));
	miIconify.setOnAction(e ->
	{
		contextMenu.hide();
		propIcon.set(true);
	});
	
	miMaximize = new MenuItem("Maximize");
	miMaximize.setGraphic(irMaxMenu);
	miMaximize.setOnAction(e ->
	{
		contextMenu.hide();
		propMax.set(!propMax.get());
	});
	
	sepFullScreen = new SeparatorMenuItem();
	
	miFullScreen = new MenuItem("Fullscreen");
	miFullScreen.setGraphic(new FXImageRegion(new Image("/com/sibvisions/rad/ui/javafx/ext/scene/css/fullscreen_menu.png")));
	miFullScreen.setOnAction(e ->
	{
		contextMenu.hide();
		propFullScreen.set(true);
	});
	miFullScreen.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN));
	
	sepClose = new SeparatorMenuItem();
	
	miClose = new MenuItem("Close");
	miClose.setGraphic(new FXImageRegion(new Image("/com/sibvisions/rad/ui/javafx/ext/scene/css/close_menu.png")));
	miClose.setOnAction(e ->
	{
		contextMenu.hide();
		propClose.set(true);
	});
	miClose.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN));
	
	contextMenu.getItems().addAll(miIconify, miMaximize, sepFullScreen, miFullScreen, sepClose, miClose);
}
 
开发者ID:ivartanian,项目名称:JVx.javafx,代码行数:50,代码来源:StackedScenePane.java


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