Вопрос

Have been trying to run my JavaFX 2.2 app in JavaFX 8 (8u5), and have consistently been encountering this error:

Caused by: javafx.fxml.LoadException: Error resolving onMouseClicked=
'#chooseClient', either the event handler is not in the Namespace or there
is an error in the script. /C:/Users/Viktor/app/bin/main/fxml/layout.fxml:301

My code seems completely fine and, most importantly, everything worked perfectly in JavaFx 2.2!! The chooseclient method that it refers to is declared as such:

@FXML protected static void chooseClient() { /* code here */ }

As hinted in this question, I did a find and replace operation to change all instances of the words 'private' and 'protected' to 'public'. No change, still got the same error.

I am exporting my application as a .jar file from eclipse and running it through the command line (Windows) with

"C:\Program Files\Java\jdk1.8.0_05\jre\bin\java.exe" -jar cClient.jar

Hitting 'run' in eclipse results in an identical error.

Running the exactly same exported jar but with JavaFx 2.2 results in no issues at all. Could this be a bug? Very confused as to what could be causing the issue. Any help is much appreciated.

Это было полезно?

Решение

I believe support for static access via @FXML disappeared in JavaFX 8. Remove the static modifier.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top