• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

MVC, multiple windows, JavaFX

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I have to make a form using the MVC model. So FXML and stuff. I just got an obscure list of exceptions, I think the error is in the initialize method, specifically in the choicebox bindings, but I have no idea how to fix it.
I am not even half way through, so I dont have a CSS file yet and still missing a lot of funcionalities, just please ignore those, all I need is for the window to appear, and I lost it when I made the controller class.

Main class


view FXML file



model



controller

 
Rancher
Posts: 3391
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I just got an obscure list of exceptions, I think the error is ...


If there are any messages please copy and paste here the full text.

Note: Line 97 is way too long.  It causes the displayed page to be too wide to view without shifting.

Maybe a moderator and fold it.
 
Amadeus Pan
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:

I just got an obscure list of exceptions, I think the error is ...


If there are any messages please copy and paste here the full text.

Note: Line 97 is way too long.  It causes the displayed page to be too wide to view without shifting.

Maybe a moderator and fold it.



I am pretty sure now that the problem is in line 11 of the FXML file, the fx:controller="controller.InternetPacketController" bit. If I take it out it all works.
So there or in the controller class somewhere.

here is the list of exceptions an errors I get.

run:
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$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
/C:/Documents/NetBeansProjects/InternetPackets/build/classes/view/add_packet.fxml

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2543)
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 main.Main.start(Main.java:24)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[11,62]
Message: Element type "GridPane" must be followed by either attribute specifications, ">" or "/>".
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:596)
at javax.xml.stream.util.StreamReaderDelegate.next(StreamReaderDelegate.java:88)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2513)
... 17 more
Exception running application main.Main
C:\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 2 seconds)
 
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[11,62]



There's an error in your fxmlfile. What idea are you using? It should warn you about it
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it should be something like:

 
Sheriff
Posts: 6039
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ok so I have to make a form using the MVC model. So FXML and stuff.


Just a note that MVC and FXML are two different technologies.  You can have an MVC app without FXML.
 
Knute Snortum
Sheriff
Posts: 6039
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Edit: see post below]

Your app suffers from a known bug in FXML technology: the FXML files have to be in the same package as the controllers.  I know this messes with the whole MVC thing, but there it is.

Since you say, "I have to make a form..." I don't know if this is a personal project or something for school.  If it's the latter, you may have to explain this bug to your instructor.  Either that or you can abandon FXML and write the GUI in code.  Yes, I know, that sucks.

https://stackoverflow.com/questions/28830132/scenebuilder-2-do-controller-classes-need-to-necessarily-be-in-the-same-folder

(Note: since this says the bug is in SceneBuilder, maybe you can manually edit the FXML files to correct the problem.  I'll investigate.)
 
Knute Snortum
Sheriff
Posts: 6039
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Evidently this is only a SceneBuilder problem, not a JavaFX problem.  You can put your FXML files in a different package than the controller.  The only problem is that SceneBuilder then will not be able to access your controller to check whether the IDs you're assigning are correct.

A way around this is to create the FXML files in the same package as the controller, enter your controller into SceneBuilder and all the fx IDs, then move the FXML file to its own package.  That, or just put up with the warnings in SceneBuilder.
 
Knute Snortum
Sheriff
Posts: 6039
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One other thing I think you're going to run into is related to this code:
You have a no-args constructor with package-private (default) accessibility. The problem will be when JavaFX needs to inspect the fields, it won't be able to instantiate the class.  To solve this either a) make the constructor public (not the best), or b) make it @FXML private (better), or c) just remove the constructor as it doesn't do anything useful.
 
Amadeus Pan
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:[Edit: see post below]

Your app suffers from a known bug in FXML technology: the FXML files have to be in the same package as the controllers.  I know this messes with the whole MVC thing, but there it is.

Since you say, "I have to make a form..." I don't know if this is a personal project or something for school.  If it's the latter, you may have to explain this bug to your instructor.  Either that or you can abandon FXML and write the GUI in code.  Yes, I know, that sucks.

https://stackoverflow.com/questions/28830132/scenebuilder-2-do-controller-classes-need-to-necessarily-be-in-the-same-folder

(Note: since this says the bug is in SceneBuilder, maybe you can manually edit the FXML files to correct the problem.  I'll investigate.)



Thank you so much. It is for school. I let my professor know and asked him how to deal with this without losing credits.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:[Edit: see post below]

Your app suffers from a known bug in FXML technology: the FXML files have to be in the same package as the controllers.  I know this messes with the whole MVC thing, but there it is.

Since you say, "I have to make a form..." I don't know if this is a personal project or something for school.  If it's the latter, you may have to explain this bug to your instructor.  Either that or you can abandon FXML and write the GUI in code.  Yes, I know, that sucks.

https://stackoverflow.com/questions/28830132/scenebuilder-2-do-controller-classes-need-to-necessarily-be-in-the-same-folder

(Note: since this says the bug is in SceneBuilder, maybe you can manually edit the FXML files to correct the problem.  I'll investigate.)



It have no problems with seperating the both and using scenebuilder. i don't know if it's because I'm using spring or cause I use the fully qualified name, but I would try the lather before talking to your teacher.

 
Knute Snortum
Sheriff
Posts: 6039
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:Evidently this is only a SceneBuilder problem, not a JavaFX problem.  You can put your FXML files in a different package than the controller.  The only problem is that SceneBuilder then will not be able to access your controller to check whether the IDs you're assigning are correct.

A way around this is to create the FXML files in the same package as the controller, enter your controller into SceneBuilder and all the fx IDs, then move the FXML file to its own package.  That, or just put up with the warnings in SceneBuilder.


I did write this follow-up post and put a message in the original post pointing to it.
 
Knute Snortum
Sheriff
Posts: 6039
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:It have no problems with seperating the both and using scenebuilder. i don't know if it's because I'm using spring or cause I use the fully qualified name...


That's great!  When you say fully qualified name, do you mean for the controller?  I also use a fully qualified class name (e.g. xxx.yyy.controller.PageController) but when I'm entering the member names in SceneBuilder, I get a warning message.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes starting from the srcpackage, so for me that's
The included image is the same file opend in scenebuilder
scenebuilder.png
[Thumbnail for scenebuilder.png]
 
Knute Snortum
Sheriff
Posts: 6039
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this the SceneBuilder from Gluon (http://gluonhq.com/products/scene-builder/) or the one in NetBeans?
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Amadeus: Which idea do you use, dosn't have it an build in scene builder? That also could fix your problem
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from gluon
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!