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 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 is similar to the previous one, the main difference is that it will return the url of the current source file.

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

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:
Then you can retrieve the value this way:
 var codebase = FX.getProperty("javafx.application.codebase");