Java Reference
In-Depth Information
When the application is launched as a Web Start app or as browser-embedded applet, we get
the same result, shown in the next screenshot:
How it works...
The JavaFX application framework provides a uniform way to access application arguments.
In the code above, function FX.getParameter(name:String):String is used to look up
an argument by name passed into the application at runtime, either as a Web Start desktop
application or as a browser-embedded applet.
The JavaFX application framework uses a key/value pair to represent the argument passed
into an application at runtime. Let's see how that works:
F Arguments through Web Start —for Web Start desktop applications, arguments
are specified in the JNLP descriptor file. All JavaFX arguments must take the
form of key=value using the <argument/> tag. For our example, we specify
<argument>name=World</argument> .
F Arguments through Applet —for applets, the Java Plugin reads runtime argument
values from the JavaScript applet bootstrapping code embedded in the HTML. There,
the argument is a {key:value} entry in an associative array passed as the second
argument of the javafx() function (see code above). For our example, we pass in
the argument as {name:"World"} .
There's more...
Accessing all arguments
The JavaFX runtime provides function FX.getArguments():String[] , which returns
a sequence of Strings containing the "key=value" strings passed in using the method
described previously.
Command-line arguments
When you run your application from the command line, you can still use the key=value
mechanism to pass in arguments. The following command shows how you would launch
the application packaged in this recipe using the JavaFX command-line launcher with
runtime arguments:
javafx -jar dist/args-demo.jar name="World"
Search WWH ::

Custom Search