Monday, March 1, 2010

Useful constants in JavaFX

There are a couple of useful constants in JavaFX that for sure I'll use later in the future, check them out:

__DIR__ 
Dir will return the directory of the currently executed FX source file. A sample of how to use it would be something simple like:
 println("The current directory of this FX file is: {__DIR__});  
The value of this constant may be a jar in case you are executing this from a jar.


__FILE__ 
File is similar to the previous one, the main difference is that it will return the url of the current source file.

__PROFILE__
Profile will have only three values, "mobile","desktop" and "browser" depending on how the script was executed.

Codebase
Using the following code you will get the value of the "codebase" attribute located in the .jnlp file from your application. So in case you .jnpl file goes like this:
 codebase="http://example.sun.com/JavaFX/AppletDeploy/dist/"   
Then you can retrieve the value this way:
 var codebase = FX.getProperty("javafx.application.codebase");