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


Java Scene.addEventFilter方法代码示例

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


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

示例1: start

import javafx.scene.Scene; //导入方法依赖的package包/类
public void start(Stage primaryStage, ScrollPane rootLayout) throws Exception {
	primaryStage.setTitle("Change Hotkeys");
	Scene myScene = new Scene(rootLayout);
	ourStage = primaryStage;
	myScene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
		public void handle(KeyEvent event) {
			if (changeHotkey) {
				if (addHotkey(event, changeHotkeyFunction)) {
					changeHotkey = false;
				}
			}
		}
	});
	Label divider = new Label();
	HBox labelHbox = new HBox(divider);
	divider.setText("----These hotkeys are not changeable----");
	labelHbox.setAlignment(Pos.CENTER);
	for (String key : HOTKEYS) {
		hotkeyVBox.getChildren().add(hotkeys.get(key).getHotkeyHBox());
	}
	hotkeyVBox.getChildren().add(labelHbox);
	for (ImmutableHotkey hotkey : IMMUTABLE_HOTKEYS) {
		hotkeyVBox.getChildren().add(hotkey.getHotkeyHBox());
	}
	primaryStage.setScene(myScene);
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:27,代码来源:HotkeyController.java

示例2: start

import javafx.scene.Scene; //导入方法依赖的package包/类
@Override
public void start(Stage rootStage) throws Exception {
    rootStage.setMaximized(true);
    main = this;

    FXMLLoader loader = new FXMLLoader(getClass().getResource("/resources/layouts/main.fxml"));

    Parent root = loader.load();

    Scene rootScene = new Scene(root);

    rootStage.setTitle("Parallator");

    rootController = loader.getController();

    rootStage.setScene(rootScene);

    initMenu(rootStage);

    rootStage.show();
    rootStage.setOnCloseRequest(event -> {
        if (rootController.getFile() == null || !rootController.isEdited()) return;
        Alert alert = new Alert(Alert.AlertType.WARNING);
        alert.setHeaderText("Сохранить перед выходом?");
        alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
        Optional<ButtonType> result = alert.showAndWait();
        if (result.isPresent() && result.get() == ButtonType.YES) {
            rootController.save();
        }
        if (result.isPresent() && result.get() == ButtonType.CANCEL) {
            event.consume();
        }
    });

    rootScene.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
        switch (event.getCode()) {
            case DOWN:
                rootController.down();
                break;
            case UP:
                rootController.up();
                break;
        }
    });

    if (MainConfig.getMainConfig().path() != null) rootController.open(new File(MainConfig.getMainConfig().path()));
}
 
开发者ID:KursX,项目名称:Parallator,代码行数:48,代码来源:Main.java

示例3: Stats

import javafx.scene.Scene; //导入方法依赖的package包/类
public Stats(Scene gameContextScene) {
    this.gameContextScene = gameContextScene;

    nbGoals = 0;
    beginTime = 0;
    length = 0;
    zeroTime = System.currentTimeMillis();
    lengthBetweenGoals = new ArrayList<Integer>(1000);

    log.info("GazeUtils ON : " + GazeUtils.isOn());

    if (GazeUtils.isOn()) {
        recordGazeMovements = buildRecordGazeMovements();
        GazeUtils.addStats(this);
    } else {
        recordMouseMovements = buildRecordMouseMovements();
        gameContextScene.addEventFilter(MouseEvent.ANY, recordMouseMovements);
    }

    int heatMapWidth = (int) (gameContextScene.getHeight() / heatMapPixelSize);
    int heatMapHeight = (int) (gameContextScene.getWidth() / heatMapPixelSize);
    log.info("heatMapWidth = {}, heatMapHeight = {}", heatMapWidth, heatMapHeight);
    heatMap = new double[heatMapWidth][heatMapHeight];
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:25,代码来源:Stats.java

示例4: makeZoomable

import javafx.scene.Scene; //导入方法依赖的package包/类
public void makeZoomable(Scene scene4EventFilter, Node control4Scaling) {
    scene4EventFilter.addEventFilter(ScrollEvent.ANY, (ScrollEvent event) -> {
        double delta = 1.2;
        double scale = control4Scaling.getScaleX();

        if (ObjectUtils.smallerDoublePrecision(event.getDeltaY(), 0)) {
            scale /= delta;
        } else {
            scale *= delta;
        }

        if (scale < MIN_SCALE || scale > MAX_SCALE) {
            scale = scale < MIN_SCALE ? MIN_SCALE : MAX_SCALE;
        }

        control4Scaling.setScaleX(scale);
        control4Scaling.setScaleY(scale);

        event.consume();
    });
}
 
开发者ID:adihubba,项目名称:javafx-3d-surface-chart,代码行数:22,代码来源:Mesh3DChartPanel.java

示例5: start

import javafx.scene.Scene; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
	
	Parent root = GUI.initializeMainWindow(primaryStage);
	
	Scene scene = new Scene(root, 1300, 680);
	scene.addEventFilter(KeyEvent.KEY_PRESSED, (e)->{
		if(e.getCode() == KeyCode.SPACE){
			System.out.println("SPACE! THE FINAL FRONTIER!");
			
			if(emergencyStop != null){
				emergencyStop.change(true);
			}
		}
	});
	
	primaryStage.setScene(scene);
	primaryStage.setResizable(true);
	primaryStage.setOnCloseRequest((e)->{
		System.exit(0);
	});
	primaryStage.setTitle("FLASHboard");
	
	fxReady();
	primaryStage.show();
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:27,代码来源:Dashboard.java

示例6: setUpListener

import javafx.scene.Scene; //导入方法依赖的package包/类
private void setUpListener (Scene scene, Pane pane) {
    pane.requestFocus();
    pane.setOnMouseClicked(e -> queue(myEventFactory.interpretEvent(e, myScale.getScale(),
                                                                    myScale.getScale())));
    scene.addEventFilter(KeyEvent.KEY_RELEASED, e -> queue(myEventFactory.interpretEvent(e)));
    scene.addEventFilter(KeyEvent.KEY_PRESSED, e -> queue(myEventFactory.interpretEvent(e)));
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:8,代码来源:IOInterpeter.java

示例7: setupInterface

import javafx.scene.Scene; //导入方法依赖的package包/类
/**
 * Creates the canvas for scrolling and panning.
 *
 * @param primaryStage - Stage as given by the start method
 */
private void setupInterface(Stage primaryStage) {
    root = new Group();

    primaryStage.setTitle("Drone simulator");
    primaryStage.setResizable(false);
    primaryStage.setOnCloseRequest(onCloseEventHandler);

    Runtime.getRuntime().addShutdownHook(new Thread(() -> onCloseEventHandler.handle(null)));

    // create canvas
    canvas = new PannableCanvas(Settings.CANVAS_WIDTH, Settings.CANVAS_HEIGHT);
    canvas.setId("pane");
    canvas.setTranslateX(0);
    canvas.setTranslateY(0);

    root.getChildren().add(canvas);

    double width = Settings.SCENE_WIDTH > Settings.CANVAS_WIDTH ? Settings.CANVAS_WIDTH : Settings.SCENE_WIDTH;
    double height = Settings.SCENE_HEIGHT > Settings.CANVAS_HEIGHT ? Settings.CANVAS_HEIGHT : Settings.SCENE_HEIGHT;

    // create scene which can be dragged and zoomed
    Scene scene = new Scene(root, width, height);
    SceneGestures sceneGestures = new SceneGestures(canvas);
    scene.addEventFilter(MouseEvent.MOUSE_PRESSED, sceneGestures.getOnMousePressedEventHandler());
    scene.addEventFilter(MouseEvent.MOUSE_DRAGGED, sceneGestures.getOnMouseDraggedEventHandler());
    scene.addEventFilter(ScrollEvent.ANY, sceneGestures.getOnScrollEventHandler());
    scene.getStylesheets().addAll(this.getClass().getResource("/style.css").toExternalForm());

    primaryStage.setScene(scene);
    primaryStage.show();
    canvas.addGrid();
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:38,代码来源:Game.java


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