This article is the 5th of
JavaFX Advent Calendar and a sequel of
Tic-tac-toe with Clojure.
Tic-tac-toe
Since the logic of the game have been made, we only need to implement at the drawing.
Application
As the basis for JavaFX, inherit
javafx.application.Application to the main class.
In order to compile the class files of Java, we use the
gen-class.
In the
main method calls
Application.launch.
In the
start method implements
tic-tac-toe.game.Canvas and register the handler in each panel.
doto is useful when using the GUI library in Clojure.
We can run continuously some methods under the instance.
It is like the
instance_eval in Ruby.
Such an interface as
EventHandler is obtained an instance by using
reify.
Web Start
First, make a standalone jar file with
lein2 uberjar.
Then create a jnlp file.
The all-permissions are needed to run Clojure.
We must make a signature, because it requires all-permissions.
You can make the keystore by
keytool, and sign the jar using
jarsigner.
keytool -genkey -keystore foo -alias bar
jarsigner -keystore foo target/tic-tac-toe-0.1.0-SNAPSHOT-standalone.jar bar
You can start with Web Start.
If you try on local environment, rewrite the codebase of jnlp file.
Miscellaneous Thoughts
I think that JavaFX is simpler than Swing and we would be able to write the GUI application easily.
But I felt that the Web Start is not suitable for other required language runtime, such as the Scala and Clojure.
Because file size becomes very large.