This discussion is archived
2 Replies Latest reply: Apr 14, 2013 11:02 AM by KonradZuse RSS

eventHandler<T> T doesn't recognize KeyEvent, bug?

KonradZuse Explorer
Currently Being Moderated
"type argument KeyEvent is not within bounds of Type-Variable T

where T is a Type-Variable

T extends Event declared in the interface EventHandler
{code}  this code doesn't work

Example 4-3 Handler for the Key Nodes

private void installEventHandler(final Node keyNode) {
    // handler for enter key press / release events, other keys are
    // handled by the parent (keyboard) node handler
    final EventHandler<KeyEvent> keyEventHandler =
        new EventHandler<KeyEvent>() {
            public void handle(final KeyEvent keyEvent) {
                if (keyEvent.getCode() == KeyCode.ENTER) {
                        == KeyEvent.KEY_PRESSED);

nor does this code, which I copied from a eventHandler<MouseEvent>


class keyHandler implements EventHandler<KeyEvent>
 private final Node node;

    keyHandler(Node node) 
       this.node= node ;

    public void handle(KeyEvent event)


I'm going to make a jira report once I get confirmation from someone here, even though it's pretty obvious since the Tutorial example produced the same error.

I am using Netbeans Lambda 8, with JDK 8 build-84

InputEvent doesn't work either, going to try some others...  so far MouseEvent and DragEvent are the only working ones.

Edited by: KonradZuse on Apr 13, 2013 10:44 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    


  • Correct Answers - 10 points
  • Helpful Answers - 5 points