简体   繁体   中英

issues with setting up javafx package controllers

I am trying to organize my project , but when I try to load my controller , and I got java.lang.reflect.InvocationTargetException but I have the right path. how can I fix this?

<AnchorPane id="AnchorPane" prefHeight="570.0" prefWidth="784.0" styleClass="root" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="user.ui.main.StrixController">

error

file:/home/xxxx/NetBeansProjects/strixx/dist/run385118534/xxxx.jar!/user/ui/main/strix.fxml:10

treeview

├── resources
│   ├── images
│   │   ├── 156081805144861603.png
│   │   └── icon
│   │       ├── blueGlass.png
│   │       ├── exploit.png
│   │       ├── icon.png
│   │       └── shaker.png
│   └── theme
│       └── dark.theme.css
├── strix
│   └── ui
│       ├── about
│       │   ├── aboutController.java
│       │   └── about.fxml
│       └── main
│           ├── StrixController.java
│           ├── strix.fxml
│           └── Strix.java
└── util
    └── strixUtil.java

Executing /home/blackleitus/NetBeansProjects/JavaFXApplication11/dist/run981614013/JavaFXApplication11.jar using platform /usr/lib/jvm/java-8-oracle/jre/bin/java
Gtk-Message: 00:24:34.842: Failed to load module "pantheon-filechooser-module"

(java:17030): Gtk-WARNING **: 00:24:34.848: Unable to locate theme engine in module_path: "pixmap",

(java:17030): Gtk-WARNING **: 00:24:34.848: Unable to locate theme engine in module_path: "pixmap",

(java:17030): Gtk-WARNING **: 00:24:34.848: Unable to locate theme engine in module_path: "pixmap",

(java:17030): Gtk-WARNING **: 00:24:34.848: Unable to locate theme engine in module_path: "pixmap",
Gtk-Message: 00:24:34.849: Failed to load module "canberra-gtk-module"
Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$412(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException: Error resolving onAction='#handleAboutAction', either the event handler is not in the Namespace or there is an error in the script.
file:/home/blackleitus/NetBeansProjects/JavaFXApplication11/dist/run981614013/JavaFXApplication11.jar!/javafxapplication11/ui/main/FXMLDocument.fxml:26

    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
    at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
    at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:610)
    at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770)
    at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
    at javafxapplication11.ui.main.JavaFXApplication11.start(JavaFXApplication11.java:22)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$419(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$399(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$397(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$398(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$203(GtkApplication.java:139)
    ... 1 more
Exception running application javafxapplication11.ui.main.JavaFXApplication11
Java Result: 1

Looks like your problem is not in the path

Caused by: javafx.fxml.LoadException: Error resolving onAction='#handleAboutAction', either 
the event handler is not in the Namespace or there is an error in the script.
file:/home/blackleitus/NetBeansProjects/JavaFXApplication11/dist/run981614013/JavaFXApplication11.jar!/javafxapplication11/ui/main/FXMLDocument.fxml:26

the problem is that the loader is not finding the method handleAboutAction in the controller try checking the method name spelling in the fxml and in the controller

I Hope this works (tell me if not)

Your are missing the Event Function

   @FXML
    void handleAboutAction(ActionEvent event) {

    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM