982603 wrote:Sort of. When the FXML file is loaded, objects are instantiated based on the content of the FXML file and will exist in memory. The FXMLLoader.load() method returns the object representing the root of the fxml document (which will probably have references to other objects, etc). Some objects may also be injected into the controller (so the controller has references to them). Once the FXML file has been parsed, methods on the objects which were instantiated are invoked in the normal fashion (i.e. the FXML file is no longer needed). So you can regard the FXML file as being parsed once, rather than "interpreted" in the traditional sense.
Narayan, Thanks for your quick reply. Let me understand something, JavaFX takes FXML file and runs in real time in the style of an interpreted language?
For the tests I've done, if it has an associated FXML controller, it must be compiled.The FMXLLoader.load(...) method takes a parameter of type URL. So you can pass any URL object in here: see http://docs.oracle.com/javase/7/docs/api/java/net/URL.html The getClass().getResource(...) method, at least on an intuitive level, constructs a URL which represents loading the resource from "the same place this class was loaded". So if you're running directly from the file system (which you shouldn't be, for a JavaFX application), it will be a URL pointing to the file system. If you're running from a jar file, it will look for the resource in the jar file. (This is something of a simplification, but it a good starting point. The complete details are at http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getResource(java.lang.String) [You probably need to edit the link in your browser to include "(java.lang.String)", which is intended to be part fo the url.]).
How I can do to load a FXML that haves a controller but both are in a different path to the application that invokes it? I understand that using FXMLLoader.load (getClass (). GetResource ()), we are invoking a resource within the project prepackaged, or am I wrong?
If so, what is the best practice to load drivers that are referenced FXML and what is the way to unload them?I'm not sure what you mean by "drivers" here. The best practice to load FXML files is to bundle them with your application, and load them using getClass().getResource(...). If you are building an application in which the FXML would be loaded from the file system, you could call FXMLLoader.load(new URL("file:///path/to/my/file.fxml")). (But how would you ensure the FXML file was there?) If you were (for some reason) loading an FXML file from a web server, you could call FXMLLoader.load(new URL("http://my.server.com/my/file.fxml")).
Thanks and Regards,
JavaFX takes FXML file and runs in real time in the style of an interpreted language?I'd think of the FXMLLoader as more like a web browser loading HTML.
How I can do to load a FXML that haves a controller but both are in a different path to the application that invokes it?The FXMLLoader load method has a url paramater to specify the location of where the source FXML file originates - it works in the same way as entering a URL into your web browser's location bar.
I understand that using FXMLLoader.load(getClass().getResource()), we are invoking a resource within the project prepackaged, or am I wrong?Pretty much correct. getClass().getResource() will use the originating codebase of the classloader, which will generally be the source jar for the application. But you don't have to load a resource like this, you can use any url you like (within the Java security sandbox which currently doesn't really apply to FXML anyway as FXML won't execute within any kind of security sandbox as of JavaFX 2.2).
If so, what is the best practice to load drivers that are referenced FXML and what is the way to unload them?With FXML, you can define your own components and tags to extend the language; i.e. it does not have a fixed tagset. In addition to the extensive set of components provided by the JavaFX system, you can easily define your own custom components. Perhaps these are like your notion of drivers and plugins (which I have to admit is hard for me to understand)?