2 Replies Latest reply: Apr 14, 2013 1:02 PM by KonradZuse RSS

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

    KonradZuse
      "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}
      
      
      http://docs.oracle.com/javafx/2/events/handlers.htm  this code doesn't work
      
      {code}
      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) {
                          setPressed(keyEvent.getEventType()
                              == KeyEvent.KEY_PRESSED);
       
                          keyEvent.consume();
                      }
                  }
              };
       
          keyNode.setOnKeyPressed(keyEventHandler);
          keyNode.setOnKeyReleased(keyEventHandler);
      }
      {code}
      
      
      nor does this code, which I copied from a eventHandler<MouseEvent>
      
      {code}
      
      class keyHandler implements EventHandler<KeyEvent>
      {
       private final Node node;
      
          keyHandler(Node node) 
          {
             this.node= node ;
      
          } 
       
          @Override
          public void handle(KeyEvent event)
          {
          }    
        }
      
      {code}
      
      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