JavaFX Preview Release Transition Guide

JavaFX has a very rich language and set of APIs which have changed quite a bit on their way to the 1.0 release. If you wrote code with the preview release last July, or an even earlier release, then you will notice that your code no longer compiles. If you'd like to update your old code, then this is the blog for you. It would be impossible to list everything that has changed (even since the preview release in July), but here is a quick list of the big changes and a link to learn more.

Step 1: Make sure you have the new NetBeans 6.5 + JavaFX SDK bundle. Tons of things have changed so you *must* have the new bits.

Step 2: If you have an existing JavaFX project, when you open it be sure to change the JavaFX SDK used to the latest one in your Project Properties.

Step 3: Compile and see what breaks. Here's what I typically change, in order:

  • attribute to var
  • operation to function
  • private to nothing. variables are private by default now
  • static, move static functions and variables outside of your class definition
  • change javafx.ui imports to javafx.scene. (if you have code from back then)
  • javafx.scene to javafx.scene.* we split out lots of packages. For example, images are in javafx.scene.image, and colors are in javafx.scene.paint
  • javafx.input to javafx.scene.input
  • Frame, Window and Dialog are gone. Use javafx.stage.Stage instead.
  • Canvas is gone, use javafx.stage.Scene instead
  • System.out.println to println. println is built in now, so you don't need the Java version.

For a more detailed list of changes please read Stephen Chin's blog entry on the topic. Stephen has moved a rather large codebase, WidgetFX, so he put together a very comprehensive summary. Thanks Steve!

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.