本文整理汇总了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;
}
示例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());
}
}
示例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);
}