Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaFX setOnMousePressed in class Node cannot be applied to given types

 
Ashley Bye
Ranch Hand
Posts: 132
2
Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am following the StageCoachMain example in Pro JavaFX 2, in chapter 2. However, using NetBeans, for the following section of code:



Which gives the following error (setOnMouseDragged is the same error, method name changed):

method setOnMousePressed in class Node cannot be applied to given types;
required: EventHandler<? super MouseEvent>
found: anonymous EventHandler<MouseEvent>
reason: actual argument <anonymous EventHandler<MouseEvent> cannot be converted to EventHandler<? super MouseEvent> by method invocation conversion.


I have no idea what this means, or why it is caused. Interestingly, the code compiles and runs, although I don't know if properly as I don't know how the errors are affecting it and the rest of the example isn't covered until later in the chapter. What is causing this, how do I fix it and why does it still run with these errors?

As an aside, how do I supply a runtime argument (ie transparent, undecorated) to NetBeans? The book says via Properties -> Run : Arguments, but this does not exist.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic