Learning JavaFX? Join me..
By mohanpraveen on Aug 07, 2007
JavaFX has been creating lot of buzz since JavaOne'2007 and I could not overcome the temptation to try it out myself and see how it brings down the complexity of developing Rich UI contents. I have been into the Quality side of Java2D/AWT area for quite sometime and my goal is to see how easy it is to develop some cool 2D graphics and animations in FX. I am pretty much impressed with my first interaction with JavaFX.
I am still in the process of learning JavaFX and my Java knowledge hampers the learning process a bit. That's because JavaFX offers the flexibility of writing Java code and calling Java programs from within the FX script and I often tend to misuse that flexibility even in the places where FX offers much more easier ways of doing things than Java (primarily due to the declarative syntax for the UI). Due to this fact, I am getting more cautious now when I am about to write something in Java inside the FX script.
Nevertheless, it is good to share whatever I have developed so far -
I had this game written in Java and I just wanted to port it to JavaFX. It was pretty easy in fact and I was able to do it in a few hours (That's actually good considering that I am just a newbie with FX syntax and semantics). But pardon me for some Java code that I have put in the script and I will be migrating them to FX as I climb up the FX ladder.
I have used the Swing Timer class to do the animations to start with. I was really excited about the simplicity with which I can move the ball/bat, just by changing the x,y property and binding takes care of updating the UI.
Just try it yourself (You would need jdk6+. It might take a couple of minutes to load, the first time) -
Here is the script -
I am in the processing of writing few other apps in the 2D/Swing area and I swear it will have more FX stuff than Java. Stay Tuned !!