title: Object initializes despite wrong values to constructor?
body: <pre><code>Timeline pongAnimation = TimelineBuilder.create()
      .keyFrames(
        new KeyFrame(
          new Duration(10.0),
          new EventHandler&lt;ActionEvent&gt;() {
            public void handle(javafx.event.ActionEvent t) {
              checkForCollision();
              int horzPixels = movingRight ? 1 : -1;
              int vertPixels = movingDown ? 1 : -1;
              centerX.setValue(centerX.getValue() + horzPixels);
              centerY.setValue(centerY.getValue() + vertPixels);
            }
          }
        )
      )
      .cycleCount(Timeline.INDEFINITE)
      .build();  
  </code></pre>
  
  <p>This is the JavaFX code from the book that I am reading. It is creating a <code>KeyFrame</code> by passing it a <code>Duration</code> and an <code>EventListener</code>-- no more, no less.  </p>
  
  <p>All the constructors for <code>Timeline</code> class that are associated with the <code>EventHandler</code> need <code>KeyValues</code> as argument. However, that is not the case in the code above. The code compiles and even gives the desired output.   </p>
  
  <p><strong>Why?</strong>  </p>
  
  <p>Docs: <a href="http://docs.oracle.com/javafx/2/api/javafx/animation/KeyFrame.html" rel="nofollow">http://docs.oracle.com/javafx/2/api/javafx/animation/KeyFrame.html</a></p>