javafx.scene.Scene#setOnKeyReleased ( )源码实例Demo

下面列出了javafx.scene.Scene#setOnKeyReleased ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FXTutorials   文件: Main.java
@Override
public void start(Stage primaryStage) throws Exception {
    Scene scene = new Scene(appRoot);
    scene.setOnKeyPressed(event -> keys.put(event.getCode(), true));
    scene.setOnKeyReleased(event -> keys.put(event.getCode(), false));
    primaryStage.setTitle("Tutorial 14 Platformer");
    primaryStage.setScene(scene);
    primaryStage.show();

    AnimationTimer timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            update();
        }
    };
    timer.start();
}
 
源代码2 项目: pdfsam   文件: LogStage.java
@Inject
public LogStage(LogPane logPane, LogListView logView, List<Image> logos, StylesConfig styles) {
    BorderPane containerPane = new BorderPane();
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.setCenter(logPane);
    containerPane.setBottom(new ClosePane((a) -> eventStudio().broadcast(HideStageRequest.INSTANCE, "LogStage")));
    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(k -> {
        if (this.isShowing() && new KeyCodeCombination(KeyCode.ESCAPE).match(k)) {
            eventStudio().broadcast(HideStageRequest.INSTANCE, "LogStage");
        }
    });
    setScene(scene);
    setTitle(DefaultI18nContext.getInstance().i18n("Log register"));
    getIcons().addAll(logos);
    setMaximized(true);
    eventStudio().addAnnotatedListeners(this);
    this.onShowingProperty().addListener((o, oldVal, newVal) -> logView.scrollToBottomIfShowing());
    eventStudio().add(logView, LOGSTAGE_EVENTSTATION);
}
 
源代码3 项目: mcaselector   文件: Window.java
@Override
public void start(Stage primaryStage) {
	try {
		primaryStage.setTitle("MCA Selector " + FileHelper.getManifestAttributes().getValue("Application-Version"));
	} catch (IOException ex) {
		primaryStage.setTitle("MCA Selector - dev");
	}
	primaryStage.getIcons().add(FileHelper.getIconFromResources("img/icon"));

	TileMap tileMap = new TileMap(this, width, height);

	BorderPane pane = new BorderPane();

	//menu bar
	OptionBar optionBar = new OptionBar(tileMap, primaryStage);
	pane.setTop(optionBar);

	//tilemap
	TileMapBox tileMapBox = new TileMapBox(tileMap, primaryStage);
	pane.setCenter(tileMapBox);

	//status bar
	pane.setBottom(new StatusBar(tileMap));

	Scene scene = new Scene(pane, width, height);

	URL cssRes = Window.class.getClassLoader().getResource("style.css");
	if (cssRes != null) {
		String styleSheet = cssRes.toExternalForm();
		scene.getStylesheets().add(styleSheet);
	}

	scene.setOnKeyPressed(e -> pressedKeys.add(e.getCode()));
	scene.setOnKeyReleased(e -> pressedKeys.remove(e.getCode()));

	primaryStage.setOnCloseRequest(e -> System.exit(0));
	primaryStage.setScene(scene);
	primaryStage.show();
}
 
源代码4 项目: arma-dialog-creator   文件: ADCWindow.java
public void initialize() {
	preInit = false;
	rootElement = new VBox();
	Scene scene = stage.getScene();
	scene.setRoot(rootElement);

	FXUtil.runWhenVisible(rootElement, new Runnable() {
		@Override
		public void run() {
			canvasView = new ADCCanvasView();
			mainMenuBar = new ADCMenuBar();

			rootElement.getChildren().addAll(mainMenuBar, canvasView);

			//force canvas to render at proper size
			autoResizeCanvasView();
		}
	});


	EventHandler<KeyEvent> keyEvent = new EventHandler<KeyEvent>() {
		@Override
		public void handle(KeyEvent event) {
			canvasView.keyEvent(event.getText(), event.getEventType() == KeyEvent.KEY_PRESSED, event.isShiftDown(), event.isControlDown(), event.isAltDown());
		}
	};
	scene.setOnKeyPressed(keyEvent);
	scene.setOnKeyReleased(keyEvent);
	scene.getMnemonics().clear();

}
 
源代码5 项目: FXTutorials   文件: DrawingApp.java
@Override
public void start(Stage stage) throws Exception {
    Scene scene = new Scene(createContent());
    scene.setOnKeyReleased(e -> {
        if (e.getCode() == KeyCode.ENTER) {
            saveScreenshot(scene);
        }
    });

    stage.setScene(scene);
    stage.show();
}
 
源代码6 项目: FXTutorials   文件: Main.java
@Override
public void start(Stage primaryStage) throws Exception {
    Scene scene = new Scene(createContent());
    scene.setOnKeyPressed(event -> {
        switch (event.getCode()) {
            case A:
                action = UserAction.LEFT;
                break;
            case D:
                action = UserAction.RIGHT;
                break;
        }
    });

    scene.setOnKeyReleased(event -> {
        switch (event.getCode()) {
            case A:
                action = UserAction.NONE;
                break;
            case D:
                action = UserAction.NONE;
                break;
        }
    });

    primaryStage.setTitle("Tutorial");
    primaryStage.setScene(scene);
    primaryStage.show();
    startGame();
}
 
源代码7 项目: FXTutorials   文件: Main.java
@Override
public void start(Stage primaryStage) throws Exception {
    initContent();

    Scene scene = new Scene(appRoot);
    scene.setOnKeyPressed(event -> keys.put(event.getCode(), true));
    scene.setOnKeyReleased(event -> keys.put(event.getCode(), false));
    primaryStage.setTitle("Tutorial 14 Platformer");
    primaryStage.setScene(scene);
    primaryStage.show();

    AnimationTimer timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            if (running) {
                update();
            }

            if (dialogEvent) {
                dialogEvent = false;
                keys.keySet().forEach(key -> keys.put(key, false));

                GameDialog dialog = new GameDialog();
                dialog.setOnCloseRequest(event -> {
                    if (dialog.isCorrect()) {
                        System.out.println("Correct");
                    }
                    else {
                        System.out.println("Wrong");
                    }

                    running = true;
                });
                dialog.open();
            }
        }
    };
    timer.start();
}
 
源代码8 项目: pdfsam   文件: InfoStage.java
@Inject
public InfoStage(InfoPane infoPane, List<Image> logos, StylesConfig styles) {
    BorderPane containerPane = new BorderPane();
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.setCenter(infoPane);
    containerPane.setBottom(new ClosePane());
    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(new HideOnEscapeHandler(this));
    setScene(scene);
    setTitle(DefaultI18nContext.getInstance().i18n("Document details"));
    getIcons().addAll(logos);
    setMaximized(true);
}
 
源代码9 项目: pdfsam   文件: OpenWithDialog.java
@Inject
public OpenWithDialog(StylesConfig styles, List<Module> modules) {
    initModality(Modality.WINDOW_MODAL);
    initStyle(StageStyle.UTILITY);
    setResizable(false);
    setTitle(DefaultI18nContext.getInstance().i18n("Open with"));

    this.modules = modules.stream().sorted(comparing(m -> m.descriptor().getName())).collect(toList());

    messageTitle.getStyleClass().add("-pdfsam-open-with-dialog-title");

    BorderPane containerPane = new BorderPane();
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.getStyleClass().addAll("-pdfsam-open-with-dialog", "-pdfsam-open-with-container");
    containerPane.setTop(messageTitle);
    BorderPane.setAlignment(messageTitle, Pos.TOP_CENTER);

    filesList.setPrefHeight(150);
    containerPane.setCenter(filesList);

    buttons.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.setBottom(buttons);
    BorderPane.setAlignment(buttons, Pos.CENTER);

    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(new HideOnEscapeHandler(this));
    setScene(scene);
    eventStudio().addAnnotatedListeners(this);
}
 
源代码10 项目: Aidos   文件: EventHandler.java
public static void attachEventHandlers(Scene s){
    keyReleaseHanlder krh = new keyReleaseHanlder();
    keyPressedHandler kph = new keyPressedHandler();
    s.setOnKeyReleased(krh);
    s.setOnKeyPressed(kph);
}
 
源代码11 项目: Recaf   文件: ConfKeybinding.java
/**
 * Register window-level keybinds.
 *
 * @param controller
 * 		Controller to call actions on.
 * @param stage
 * 		Window to register keys on.
 * @param scene
 * 		Scene in the window.
 */
public void registerWindowKeys(GuiController controller, Stage stage, Scene scene) {
	scene.setOnKeyReleased(e -> handleWindowKeyEvents(e, controller, stage, false));
}
 
源代码12 项目: Recaf   文件: ConfKeybinding.java
/**
 * Register window-level keybinds.
 *
 * @param controller
 * 		Controller to call actions on.
 * @param stage
 * 		Window to register keys on.
 * @param scene
 * 		Scene in the window.
 */
public void registerMainWindowKeys(GuiController controller, Stage stage, Scene scene) {
	scene.setOnKeyReleased(e -> handleWindowKeyEvents(e, controller, stage, true));
}