I generated an FXML using scene builder. Now the problem is when I try to integrate it I get a bunch of exception lines. Does anyone else stumble upon this problem ?

Apr 23, 2012 2:33:40 AM javafx.fxml.FXMLLoader logException
SEVERE: The following error occurred at line 31 in file /C:/Users/gulcoza/Documents/NetBeansProjects/Commerce/build/classes/commerce/Login.fxml[Ljava.lang.StackTraceElement;@1d59bc95
Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.javafx.main.Main.launchApp(Main.java:453)
    at com.javafx.main.Main.main(Main.java:537)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
    at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:722)
Caused by: javafx.fxml.LoadException: java.lang.InstantiationException: java.net.URL
    at javafx.fxml.FXMLLoader$InstanceDeclarationElement.constructValue(Unknown Source)
    at javafx.fxml.FXMLLoader$ValueElement.processStartElement(Unknown Source)
    at javafx.fxml.FXMLLoader.processStartElement(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at commerce.Commerce.start(Commerce.java:25)
    at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$3.run(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
    ... 1 more
Caused by: java.lang.InstantiationException: java.net.URL
    at java.lang.Class.newInstance0(Class.java:357)
    at java.lang.Class.newInstance(Class.java:325)
    ... 15 more
Java Result: 1

I assume that the FXML is fine, because it works to preview it from SceneBuilder. Thanks

有帮助吗?

解决方案

Sorry for my late reply.

  <stylesheets>
    <URL value="@style.css" />
  </stylesheets>

The line with the error is URL line. It is generated by SceneBuilder.

PS: Also updating the JavaFX version to 2.2+ should fix this issue.

其他提示

You can also remove the controller from the FXML in SceneBuilder and then manually add all the fxID's that are present in the controller java file (annotated with @FXML). The fxID's still will not be recognized after you've re-added the controller class in scenebuilder, however the fxid= "fxid name" will be added to the FXML file itself so when you run the javaFX program it will work.

Well, its hard to understand anything without your fxml file or code. But anyway: does this bug happens with all your projects or only with this one? If not only this - maybe you use old version of javafx sdk or some other global configurations are wrong. If only this one has this problem - try to delete component by component from your FXML file, to localize the problem.

Well, not how to load the FXML but this way I did that error

primaryStage.setTitle ("FXML TableView Example");
    primaryStage.setScene
    ((Scene) FXMLLoader.load (getClass (). GetResource ("fxml_tableview.fxml")));
    primaryStage.show();

 

That way if I run:

Parent FXMLLoader.load root = (getClass (). GetResource ("Prueba.fxml"));
     primaryStage.setTitle ("FXML TableView Example");
     primaryStage.setScene (new Scene (root));
     primaryStage.show ();

Hope this helps.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top