I recently upgraded my java 7 to java 8. I have an application that accepts an event with a key pressed and checks if it is a navigation key from the keyboard and acts accordingly. Below is mcve
My controller code:
package sample;
import javafx.fxml.FXML;
import javafx.scene.input.KeyEvent;
public class Controller {
@FXML
private void keyPressed(KeyEvent evt) {
System.out.println("Key Pressed");
}
}
My FXML file:
<?xml version="1.0" encoding="UTF-8"?>
//I removed all the imports in this post... My original fxml has all the imports...
<GridPane id="gridPaneId" alignment="CENTER" focusTraversable="true"
gridLinesVisible="true" hgap="10.0" onKeyPressed="#keyPressed" prefHeight="400.0"
prefWidth="300.0" vgap="10.0" xmlns:fx="http://javafx.com/fxml/1"
xmlns="http://javafx.com/javafx/2.2" fx:controller="sample.Controller" />
The problem is that my code works completely if I run it using Java 7. When I try to run it using java 8, my user interface appears without any problems, but the program does not recognize the event with the key pressed. What could be the reason.
source
share