permaculture playing cards*
The moose likes JavaFX and the fly likes JavaFX setOnMousePressed in class Node cannot be applied to given types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "JavaFX setOnMousePressed in class Node cannot be applied to given types" Watch "JavaFX setOnMousePressed in class Node cannot be applied to given types" New topic
Author

JavaFX setOnMousePressed in class Node cannot be applied to given types

Ashley Bye
Ranch Hand

Joined: Jan 30, 2013
Posts: 46

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


"Twenty years from now you will be more disappointed by the things you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover." - Mark Twain
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaFX setOnMousePressed in class Node cannot be applied to given types