Menu Pilihan:
Working with JavaFX ScriptTM files
Also see Creating Rich Internet Applications with JavaFX at java.sun.com
Working with JavaFX files in JMaker
This is done in 4 steps:
- Download and copy the JavaFX jar files (you only need to do this one time)
- Set the JMaker java options to run JavaFX files - your .java files will probably still run
- Copy, paste and save the HelloWorld.fx program in a JMaker Edit Window
- Run the HelloWorld.fx program
JavaFX API documentation at sun.com
1) Download and copy the JavaFX jar files from the JavaFX website into your JDK installation. There are 3 of them:
(Note: Since posting these steps Sun appears to have discontinued the downloads and instead is requiring you to use their IDE)
(If you have more information please post to the JavaFX forum)
- Filters.jar
- javafxrt.jar
- swing-layout.jar
Note: In the following examples the .jar files are placed in the JDK6/jre/lib folder
2) Setup your java options in JMaker to run JavaFX files
Here is a sample HelloWorld.fx program downloaded from the JavaFX website.
import javafx.ui.*;
class HelloWorldModel {
attribute saying: String;
}
var model = HelloWorldModel {
saying: "Hello World"
};
var win = Frame {
title: bind "{model.saying} JavaFX"
width: 200
height: 50
content: TextField {
value: bind model.saying
}
visible: true
};
3) Copy and paste it into a JMaker Edit Window.
Save it as HelloWorld.fx in the C:\JDK6\bin folder
4) Run it by pressing the "Run" button in the Edit Window
Your HelloWorld.fx program running should look something like this:
Summary
To work with JavaFX files and to run the HelloWorld.fx example:
- Download and copy the JavaFX jar files into your JDK installation. In this example they are in the C:/JDK6/jre/lib folder
- Set up your JMaker java options as shown above - be sure the lib path in the "-cp" java option matches your lib path
- Copy and paste the HelloWorld.fx example above into a JMaker Edit Window
- Save it as HelloWorld.fx in your JDK\bin folder
- Press the "run" button
Notes:
The java command to run HelloWorld.fx will look like this:
C:\JDK6\bin\java -cp .;C:\JDK6\jre\lib\javafxrt.jar;C:\JDK6\jre\lib\Filters.jar;C:\JDK6\jre\lib\swing-layout.jar net.java.javafx.FXShell HelloWorld
In this example: | |
---|---|
The java.exe file is in | C:\JDK6\bin |
The JavaFX jar files are in | C:\JDK6\jre\lib |
The classpath is | .;C:\JDK6\jre\lib\javafxrt.jar;C:\JDK6\jre\lib\Filters.jar;C:\JDK6\jre\lib\swing-layout.jar |
The 'other' options is | net.java.javafx.FXShell |
The .fx filename is | HelloWorld |
The HelloWorld.fx file is saved in | C:\JDK6\bin |
The working directory (where your prompt would be = PWD | C:\JDK6\bin |
Packaged is not selected | The HelloWorld.fx example is not packaged |
The JMaker run process window output will be something like this:
(The lines are numbered for clarity)
- C:\JDK6\bin\java -cp .;C:\JDK6\jre\lib\javafxrt.jar;C:\JDK6\jre\lib\Filters.jar;C:\JDK6\jre\lib\swing-layout.jar net.java.javafx.FXShell HelloWorld
- compile thread: Thread[AWT-EventQueue-0,6,main]
- compile 1.328
- init: 0.672
- C:\JDK6\bin\java -cp .;C:\JDK6\jre\lib\javafxrt.jar;C:\JDK6\jre\lib\Filters.jar;C:\JDK6\jre\lib\swing-layout.jar net.java.javafx.FXShell HelloWorld
- is done.
Note:You can double-click on error messages in the run process window to highlight them in the Edit Window source.
You can find more cool JavaFX examples at:
https://openjfx.dev.java.net/Getting_Started_With_JavaFX.html
Don't forget the import javafx.ui.*; at the top of the file!
How to put your .fx source files in a different folder
You can append your source folder path(s) to the -cp option:
Here is an example that lets you put your source.fx files in the C:\JDK6\source folder
- -cp .;C:\JDK6\jre\lib\javafxrt.jar;C:\JDK6\jre\lib\Filters.jar;C:\JDK6\jre\lib\swing-layout.jar;C:\JDK6\source
Notice the ";C:\JDK6\source" appended to the end of the -cp option
You can also change this by changing the JMaker working directory.
At the prompt it might look like this:
- cd \C:\JDK6\source
- \C:\JDK6\bin\java jmaker1.JMaker1
See JavaFX Demos for ideas about how to work with the JavaFX demo files in JMaker.
Yang Sering Dibaca:
-
It is a game like program for my kids, or say it is some fun for everyone. You can make a wish and place it on a Wish Tree. Hopefully...
-
What about shape? One thing that bothers women to no end is the fact that our breasts are not symmetrical. One is slightly larger or shape...
0 comments: