tiran1984
Posts: 1
Joined: Thu Apr 27, 2017 9:59 pm

javafx logitech k400 keyevent

Thu Apr 27, 2017 10:06 pm

Hallo

I try to create a simple javafx application which listen to an key event.
The problem is, with a USB cable keywork i get an event, with wireless logitech k400 I dont get an key event.

The Keyboard works on no java application

I use the jdk8 131 the current version of armv6hf-sdk

Code: Select all

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class HelloWorld extends Application {

	@Override
	public void start(Stage primaryStage) {
		Button btn = new Button();
		btn.setText("Say 'Hello World'");
		btn.setOnAction(new EventHandler<ActionEvent>() {

			@Override
			public void handle(ActionEvent event) {
				System.out.println("Hello World!");
			}
		});

		StackPane root = new StackPane();
		root.getChildren().add(btn);

		Scene scene = new Scene(root, 300, 250);
		scene.setOnKeyTyped(new EventHandler<KeyEvent>() {
			public void handle(KeyEvent keyEvent) {
				System.out.println(keyEvent.getText());
			}
		});

		primaryStage.setTitle("Hello World!");
		primaryStage.setScene(scene);
		primaryStage.show();
	}

	public static void main(String[] args) {
		launch(args);
	}
}

Return to “Java”

Who is online

Users browsing this forum: No registered users and 4 guests