<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Steve On Java &#187; migration</title>
	<atom:link href="http://steveonjava.com/tag/migration/feed/" rel="self" type="application/rss+xml" />
	<link>http://steveonjava.com</link>
	<description>Hacking Java, JavaFX, and Flash with Agility</description>
	<lastBuildDate>Sun, 20 May 2012 16:57:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>JavaFX 1.2 Top 10 and Migration Guide</title>
		<link>http://javafx.steveonjava.com/javafx-1-2-top-10/</link>
		<comments>http://javafx.steveonjava.com/javafx-1-2-top-10/#comments</comments>
		<pubDate>Sun, 31 May 2009 13:37:09 +0000</pubDate>
		<dc:creator>steveonjava</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[top-10]]></category>

		<guid isPermaLink="false">http://steveonjava.com/?p=269</guid>
		<description><![CDATA[Note 1: I am following Jim Weaver&#8217;s lead, since he discovered JavaFX 1.2 is downloadable from javafx.com. Enjoy the new release! Note 2: I have updated the section below on nativearray.  Please use with caution! The JavaFX 1.2 release is a huge upgrade from 1.1, both in terms of functionality and API improvements.  This means [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: left;margin-right: 0.75em;; margin-top: 4px; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fjavafx.steveonjava.com%252Fjavafx-1-2-top-10%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22JavaFX%201.2%20Top%2010%20and%20Migration%20Guide%22%20%7D);"></div>
<!--S-ButtonZ 1.1.5 Start--><div style="float: left; width: 42px; padding-right: 10px; margin: 0 10px 0 0;">
		<script type="text/javascript">
		<!--
		var dzone_url = "http://javafx.steveonjava.com/javafx-1-2-top-10/";
		var dzone_title = "JavaFX 1.2 Top 10 and Migration Guide";
		var dzone_style = "1";
		var dzone_blurb = "";
		//-->
		</script>
		<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script></div><!--S-ButtonZ 1.1.5 End--><p><span style="color:#000080;"><strong>Note 1</strong>: I am following Jim Weaver&#8217;s lead, since he discovered JavaFX 1.2 is downloadable from <a href="http://javafx.com/">javafx.com</a>. Enjoy the new release!</span></p>
<p><span style="color:#993300;"><strong>Note 2</strong>: I have updated the section below on nativearray.  Please use with caution!</span></p>
<p>The JavaFX 1.2 release is a huge upgrade from 1.1, both in terms of functionality and API improvements.  This means there are lots of cool new things to take advantage of, but at the same time you will spend quite a lot of time migrating your applications.</p>
<p>Fortunately, after upgrading <a href="http://jfxtras.org/">JFXtras</a>, <a href="http://widgetfx.org/">WidgetFX</a>, and dozens of sample applications for the <a href="http://projavafx.com/">Pro JavaFX Platform</a> book, I have this all down to a science.  In the rest of this blog I will take you through a whirlwind tour of the relevant new features, and most common migration hurdles so you can be up and running in record time!</p>
<p>First the fun stuff&#8230;  new features.  Here are the top 10 features you should start using today:</p>
<div id="attachment_312" class="wp-caption alignnone" style="width: 459px"><img class="size-full wp-image-312" title="JavaFX Top 10 Revised" src="http://steveonjava.files.wordpress.com/2009/05/javafx-1-2-top-101.jpg" alt="JavaFX Top 10 Revised" width="449" height="404" /><p class="wp-caption-text">JavaFX Top 10 Features (revised)</p></div>
<p><strong>1. Skinnable UI Controls</strong></p>
<p>It is great to have some pure JavaFX controls, such as Button, ListView, ProgressBar, and Slider that don&#8217;t rely on Swing peers underneath.  An added advantage is that they are fully skinnable to match the fonts and color palette of your application.</p>
<p><strong>2. New Layout Classes</strong></p>
<p>The new layout classes including Tile, Stack, Flow, ClipView, and Panel are a very welcome addition!  The layout API has also gotten a lot cleaner, which makes it easier to write your own layouts, such as the <a href="http://jfxtras.org/">JFXtras Grid</a>.</p>
<p><strong>3. Charting Support: Area, Bar, Bubble, Line, Pie, Scatter, X/Y</strong></p>
<p>Now I can compete with my Flex buddies on business oriented RIAs!  The new charting and graphing support is a must for any enterprise applications, so I am glad to see it made the cut.</p>
<p><strong><span id="more-269"></span>4. RSS/Atom Feed Support</strong></p>
<p>Having built-in RSS/Atom feed support is a welcome addition, and will make it much easier to write feed-based applications that cleanly port from the desktop to mobile.</p>
<p><strong>5. Local Data Storage</strong></p>
<p>An easy way to save state between sessions, no Web Start API hacking required!  See the new Resource and Storage classes in the javafx.io package for details.</p>
<p><strong>6. Stage Infrastructure: Screen and Alerts</strong></p>
<p>There is some new functionality that makes it easy to pop-up alert dialogs, or work directly with the screen bounds.  While you could have done direct Swing/Java2D hacks before, this helps keep your code mobile safe.</p>
<p><strong>7. Improved Asynchronous Processing Model</strong></p>
<p>The new Task class supercedes the AsynchronousAbstractOperation with a clean API for calling long-running tasks.  The code running in the background has to be coded in Java, but if you are looking for a JavaFX alternative see the <a href="http://jfxtras.googlecode.com/svn/site/javadoc/release-0.4/org.jfxtras.async/org.jfxtras.async.JFXWorker.html">JFXWorker</a> (which is part of the JFXtras project).</p>
<p><strong>8. BoxBlur effect</strong></p>
<p>Finally, a high-performance alternative to Gaussian blur.  This is now the default for DropShadow, which should speed up a lot of applications!</p>
<p><strong>9. Math and Properties Classes</strong></p>
<p>There are new JavaFX equivalents for java.lang.Math and java.util.Properties in the javafx.util package.  Make sure you use these instead so your application is portable to mobile.</p>
<p><strong>10. High Performance Referencing of Java Arrays (<span style="color:#993300;">updated!</span>)</strong></p>
<p>Java arrays are now optimized so that they can be used directly from JavaFX code without conversion to a sequence.  This can have a huge performance gain in programs transfering large models between Java and JavaFX code, and is transparent to the application developer.</p>
<p><strong>Note</strong>: There is experimental support for direct creation of Java arrays in JavaFX using the nativearray keyword.  Use with caution, because this functionality may be removed at any time.</p>
<p> Now that you are incentivized to upgrade, it is time to figure out how to migrate your existing applications.</p>
<h1>The Definitive 1.2 Migration Guide</h1>
<p>If you have made it this far, you are a serious JavaFX hacker!  This section covers the most common language, functionality, and API changes that you will encounter when migrating applications from JavaFX 1.1.  If you notice anything that is not covered, feel free to add it in the comments and I will update the guide as appropriate.</p>
<p><strong>General:</strong></p>
<ul>
<li><em>JavaFX 1.2 is <strong>not </strong>binary compatible</em> &#8211; If you use any jars or third-party JavaFX libraries (such as JFXtras), they must be recompiled for the new release or you will get compilation errors.  Speaking of <a href="http://jfxtras.org">JFXtras</a>, a new version which has been updated for JavaFX 1.2 is nearly ready, and will be announced here when it is complete!</li>
<li><em>All internal-only APIs are broken</em> &#8211; More details broken out by section below, but if you rely on any impl_ or com.sun packages, your code will definitely need to be updated.</li>
<li><em>Linux and Solaris are now supported</em> &#8211; This is more of a feature than a migration issue, but if you have users on multiple platforms you can now proudly state that Linux is supported.</li>
</ul>
<p><strong>Language Changes:</strong></p>
<ul>
<li><em>No more variable shadowing in nested blocks</em> &#8211; It previously was valid to name a variable the same in both the inner and outer block of an expression.  The variable in the inner block would simply replace the one in the outer.  However, this will throw a compiler error in JavaFX 1.2.  The fix is simple&#8230;  just use a different variable name.</li>
<li><em>Use Mixins instead of Multiple Inheritance</em> &#8211; JavaFX no longer supports multiple inheritance.  Instead you can extend one class and as many mixins as you like.  Mixins are like interfaces in Java, except they can have variables and implementations that are shared by all the classes that extend them.  The only change you have to make in your application to start using mixins is to add the mixin keyword when you define a new class like this:</li>
</ul>
<pre>public mixin class Resizable { /* variables and functions here */ }</pre>
<ul>
<li><em>Commas are required in sequences</em> &#8211; Sequences now require commas between elements (except those that end in braces).  This is a little less convenient, but actually a very good thing, because it avoids several language pitfalls that were hard to track down before.</li>
</ul>
<p><strong>Node Changes:</strong></p>
<ul>
<li><em>Node.boundsInScene is gone</em> &#8211; This was removed for performance reasons, fortunately there is an easy replacement that offers the same functionality:</li>
</ul>
<pre>node.localToScene(node.boundsInLocal)</pre>
<ul>
<li><em>Node.focusable -&gt; Node.focusTraversable</em> &#8211; Small API change, but good to know when you get the compilation error on focusable not found.  This is part of a larger focus fix where any Node that is visible, focusTraversable, and not disabled will be eligible for focus (a key listener is no longer required).</li>
<li><em>CustomNode.create() gets called before init</em> &#8211; Previously the CustomNode create() method would get called after init and before postinit.  Now that it gets called even earlier than init, some of your code may not work correctly.  Make sure that any variables you are depending upon in the create() method are either initialized inline or have a bind declaration so they get updated once set.</li>
<li><em>SwingControl.enabled -&gt; Node.disable</em> &#8211; There is a new disable flag on the Node class that is used universally across all controls to enable or disable them.  This conflicted with the old SwingControl.enabled variable, which has now been removed.</li>
<li><em>Rectangle2D -&gt; Bounds</em> &#8211; All references to Rectangle2D have been changed to the new javafx.geometry.Bounds class, which may have a ripple effect through your code.</li>
</ul>
<p><strong>Layout Changes:</strong></p>
<ul>
<li><em>min/max/pref -&gt; getters</em> &#8211; All of the Resizable methods (minimumWidth, minimumHeight, maximumWidth, maximumHeight, preferredWidth, preferredHeight) have been replace with function getters (getMinWidth, getMinHeight, getMaxWidth, getMaxHeight, getPrefWidth, getPrefHeight respectively).  The prefWidth/Height functions take an extra parameter, which is the amount of space in the opposite dimension.  This is very useful for doing height or width constrained layouts, such as Flows, but can be ignored by passing -1.</li>
<li><em>impl_layoutX/Y -&gt; layoutX/Y</em> &#8211; The impl_layoutX and impl_layoutY methods have been replaced with official layoutX and layoutY variables.  It is recommended that you use these variables over translateX/Y if you are moving nodes into position.</li>
<li><em>impl_requestLayout() -&gt; requestLayout()</em> &#8211; The requestLayout function has similarly moved from an internal to a public API.</li>
<li><em>impl_layout -&gt; doLayout()</em> &#8211; Rather than having a function to set the layout on, you now override Parent.doLayout().</li>
<li><em>Panel class added for declarative layouts</em> &#8211; If you are looking for a functional alternative to Container, take a look at the new Panel class, which lets you set the layout declaratively.  It also has variables to override the default min/max/pref values without subclassing Container.</li>
<li><em>New functions on Container to help with layouts</em> &#8211; There are a whole slew of new functions on the Container class that make it easier to work with the new layout system.  Make sure to read through them, because they will both save you time and help you follow the best practices for layout design.</li>
<li><em>Different transformation order</em> &#8211; Previously the transforms[] variable allowed you to apply transformations included in the layoutBounds, while scaleX/translateX/rotate etc. were applied after layout.  Now both transforms[] and the transformation variables are calculated after layout uniformly.</li>
</ul>
<p><strong>Skin/Control Changes:</strong></p>
<ul>
<li><em>Skin.scene -&gt; Skin.node</em> &#8211; The name of the Node on Skin has changed from scene to node, which helps reduce confusion with the Scene class.</li>
<li><em>Skin.compute* methods removed</em> &#8211; There were a series of computePreferredWidth/Height/etc. methods that were removed.  Instead you can directly use the getPrefWidth/Height/etc. methods on the Resizable class mentioned above.</li>
<li><em>Skin is now abstract</em> &#8211; The Skin class is now abstract, and required that you implement your own contains and intersects methods.  You can either do this by using the new JFXtras AbstractSkin class or using the following boilerplate code:</li>
</ul>
<pre>override function contains(localX:Number, localY:Number):Boolean {
    return node.contains(localX, localY);
}

override function intersects(localX:Number, localY:Number, localWidth:Number, localHeight:Number):Boolean {
    return node.intersects(localX, localY, localWidth, localHeight);
}</pre>
<ul>
<li><em>New Behavior class</em> &#8211; There is a new Behavior class that is meant to be used together with Control and Skin to provide reusable behaviors.</li>
<li><em>TextBox.text -&gt; rawText, TextBox.value -&gt; text</em> &#8211; There was some swizzling of variables on the TextBox class.  What used to be text changed to rawText, and value now has the same semantics text used to have.</li>
</ul>
<p><strong>Asynchronous Changes:</strong></p>
<ul>
<li><em>RemoteTextDocument has been removed</em> &#8211; Use HttpRequest directly instead.</li>
<li><em>AbstractAsyncOperation has been removed</em> &#8211; Use the new Task infrastructure instead for communcating with Java code running in a background thread.</li>
</ul>
<p><strong>Animation Changes:</strong></p>
<ul>
<li><em>Transition.interpolate -&gt; Transition.interpolator</em> &#8211; A small name change to make room for a new interpolate flag that allows you to turn on or off interpolation altogether.</li>
<li><em>Transition now extends Timeline </em>- This is a welcome change, which makes it much easier to work with Transitions and Timelines together.  To support this change ParallelTransition and SequentialTransition now take a sequence of Timeliens.</li>
</ul>
<p><strong>Java Equivalent Functions:</strong></p>
<ul>
<li><em>java.lang.Math -&gt; javafx.util.Math</em> &#8211; There is a new JavaFX math library, which is a drop-in replacement for the Java math library.  The main advantage of using the new JavaFX math library is that all functions are supported on mobile devices (including pow, log, etc.).</li>
<li><em>java.lang.Properties -&gt; javafx.util.Properties</em> &#8211; Another class that is similar in functionality to the Java equivalent, but portable to mobile.  Be warned, however, that the JavaFX properties file format is not the same as the standard Java properties file format.</li>
</ul>
<p><strong>CSS Changes:</strong></p>
<ul>
<li><em>CSS Update Defect (RT-4817)</em> &#8211; Stylesheet updates no longer affect newly added Nodes due to a known defect.  In the meantime, you can do this to force a stylesheet refresh:</li>
</ul>
<pre>def senators = bind model.senators on replace {
    delete sceneRef.stylesheets;
    sceneRef.stylesheets = "{__DIR__}styles.css";
}</pre>
<ul>
<li><em>CheckBoxSkin.textFill doesn&#8217;t accept styles (RT-4819) </em>- The check mark will pick up the style you set, but the text won&#8217;t.  The workaround for now is to create a checkbox with empty text and add a text node beside it with the correct styling and event handlers.</li>
<li><em>Can&#8217;t update the skin property of Control from CSS (RT-4820)</em> &#8211; Another bug in the skin support.  You can set this in code instead for now.</li>
</ul>
<p><strong>Production Suite:</strong></p>
<ul>
<li><em>UiStub -&gt; FXDNode</em> &#8211; UiStub has been replaced with FXDNode, which includes some extra functionality, such as backgroundLoading, and placeholder images.</li>
</ul>
<p><strong>Miscellaneous:</strong></p>
<ul>
<li><em>Image.fromBufferedImage() removed</em> &#8211; This has moved to SwingUtils.toFXImage().  Remember that if you use this function it will limit portability to mobile devices.</li>
<li><em>Color.fromAWTColor() removed</em> &#8211; Yet another AWT-ism that has been removed. The JavaFX Color class is pretty thorough, so there shouldn&#8217;t be any reason to work with AWT Colors.</li>
<li><em>Duration.toDate is gone</em> &#8211; As far as I know there is no equivalent functionality, but you can always get a duration&#8217;s value as a long and manipulate it directly.</li>
<li><em>Different variable names for the Affine class</em> &#8211; If you use the Affine class, then your code is likely to break due to the new, more descriptive, method names, but the functionality is the same.</li>
</ul>
<p>Whew!  &#8230;that was quite a lot to take in.  If you are interested to read more about the JavaFX 1.2 release including the new controls, layouts, and other functionality, the best source is to checkout the Pro JavaFX book that Jim, Dean, Weiqi, and I are writing.  It is almost fully updated for the JavaFX 1.2 release, and is available in Alpha right now from the <a href="http://projavafx.com/">book website</a>.</p>
<p>I want to give a special thanks to <a href="http://weblogs.java.net/blog/rbair/">Richard Bair</a> and <a href="http://weblogs.java.net/blog/aim/">Amy Fowler</a> from the Sun JavaFX team for providing a lot of valuable information on the JavaFX 1.2 release along the way.</p>
<h1>Happy hacking on JavaFX 1.2!</h1>
<div class="plus-one-wrap"><g:plusone href="http://javafx.steveonjava.com/javafx-1-2-top-10/"></g:plusone></div><div style="clear:both;">&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://javafx.steveonjava.com/javafx-1-2-top-10/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Migrating from the JavaFX Preview Release</title>
		<link>http://javafx.steveonjava.com/migrating-from-the-javafx-preview-release/</link>
		<comments>http://javafx.steveonjava.com/migrating-from-the-javafx-preview-release/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 12:50:19 +0000</pubDate>
		<dc:creator>steveonjava</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[migration]]></category>

		<guid isPermaLink="false">http://steveonjava.wordpress.com/?p=28</guid>
		<description><![CDATA[Now that the JavaFX 1.0 Release is out, it is time to dust off all your old JavaFX code and fire it up, right?  Well, not quite&#8230;  There were a whole lot of changes in the span of a few months, and it is guaranteed that your program will need a little TLC before it [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: left;margin-right: 0.75em;; margin-top: 4px; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fjavafx.steveonjava.com%252Fmigrating-from-the-javafx-preview-release%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Migrating%20from%20the%20JavaFX%20Preview%20Release%22%20%7D);"></div>
<!--S-ButtonZ 1.1.5 Start--><div style="float: left; width: 42px; padding-right: 10px; margin: 0 10px 0 0;">
		<script type="text/javascript">
		<!--
		var dzone_url = "http://javafx.steveonjava.com/migrating-from-the-javafx-preview-release/";
		var dzone_title = "Migrating from the JavaFX Preview Release";
		var dzone_style = "1";
		var dzone_blurb = "";
		//-->
		</script>
		<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script></div><!--S-ButtonZ 1.1.5 End--><p>Now that the JavaFX 1.0 Release is out, it is time to dust off all your old JavaFX code and fire it up, right?  Well, not quite&#8230;  There were a whole lot of changes in the span of a few months, and it is guaranteed that your program will need a little TLC before it runs.  Fortunately, I&#8217;ve already gone through this pain on a relatively large codebase (<a href="http://widgetfx.org/">WidgetFX</a>), and can share what I learned.</p>
<h2>Language Changes</h2>
<ul>
<li><strong>Change &#8220;attribute&#8221; to &#8220;var&#8221;/&#8221;def&#8221;</strong> &#8211; There is no more attribute keyword, but it is a simple search and replace to change it to var everywhere.  On a second pass you might want to convert vars that are never changed to def for efficiency.</li>
<li><strong>No More &#8220;static&#8221;</strong> &#8211; If you want to make a variable or function as static, just move it outside your class declaration.  If it is declared public you can access it from anywhere else just by prefacing it with the file name, no static modifier needed.</li>
<li><strong>New Access Modifiers</strong> &#8211; The default access modifier was changed to private rather than package, so you need to change any attributes or functions that had no modifier to package and then can delete all references to private.  On a second pass it may be a good idea to button-up permissions by using the new public-init and public-read permissions.  Here is a quick-reference table:<br />
<table style="border-collapse:collapse;" border="1">
<tbody>
<tr>
<th>Preview</th>
<th>1.0</th>
<th>Migration</th>
</tr>
<tr>
<td>private</td>
<td>default</td>
<td>Remove this keyword everywhere</td>
</tr>
<tr>
<td>default</td>
<td>package</td>
<td>Add package anywhere no modifier was specified</td>
</tr>
<tr>
<td>protected</td>
<td>protected</td>
<td>No change</td>
</tr>
<tr>
<td>public</td>
<td>public</td>
<td>No change</td>
</tr>
<tr>
<td>N/A</td>
<td>public-init</td>
<td>Use this anywhere the user should be able to initialize and read, but not update</td>
</tr>
<tr>
<td>N/A</td>
<td>public-read</td>
<td>Use this anywhere the user should be able to read, but not initialize or update</td>
</tr>
</tbody>
</table>
</li>
<li><strong>Required &#8220;override&#8221;</strong> &#8211; It is now mandatory that you use the override keyword on any member variable or function that exists in the superclass.  Expect to be going through lots of compiler errors to find all the places you need to fix this&#8230;</li>
<li><strong>{} Instead of &#8220;+&#8221; for Concatenating Strings</strong> &#8211; While the java-esque &#8220;+&#8221; operator for concatenating strings was an easy habit to fall into, it is no longer valid.  Instead you have to use the {} syntax to build strings.  For example, rather than &#8220;hungry for: &#8221; + meat, you would write &#8220;hungry for: {meat}&#8221;.</li>
<li><strong>Keyframe </strong><strong>Syntax</strong> &#8211; While this is not required to get your code working, there is a new KeyFrame syntax for doing animation that has the potential to make your code much shorter.  Rather than creating an instance of the KeyFrame class you can simply write &#8220;at (duration) {x =&gt; y}&#8221;.</li>
</ul>
<p><span id="more-28"></span></p>
<h2>On Applications, Stages, Scenes, and Nodes</h2>
<p>All your previous conceptions of what the terms application, stage, and scene meant have now been blown away.  For those of us who got very wired in to the old terminology, here is a quick reference from the old to the new:</p>
<table style="border-collapse:collapse;" border="1">
<tbody>
<tr>
<th>Preview</th>
<th>1.0</th>
<th>Explanation</th>
</tr>
<tr>
<td>Application</td>
<td>Stage</td>
<td>A Stage is now the top level container, which creates a Frame when run stand-alone or becomes the content area in an Applet.</td>
</tr>
<tr>
<td>Stage</td>
<td>Scene</td>
<td>The Scene is a grouping of Node content that can be added to a Stage.  It has some useful properties including the stylesheet.</td>
</tr>
<tr>
<td>Node</td>
<td>Node</td>
<td>Nodes remain largely unchanged, and are the base class of everything else that is visible in JavaFX.</td>
</tr>
</tbody>
</table>
<p>Note that you can return a Stage, Scene, or Node from your main class and they will all work within an execution context (such as an Applet).</p>
<p>Some things to note:</p>
<ul>
<li>How do I size my window? &#8211; If you want to set the outer bounds of the window, you can use the Stage width and height.  Just remember that the window decoration will reduce the content area left.  You can also set the Scene width and height, which will correctly size the window for the contents (including decorations).  Unfortunately you can only do this once, because they are public-init variables.</li>
<li>Accessing the Window &#8211; For some advanced functionality you may need to get direct access to the java.awt.Window instance underlying a Stage.  This has been taken out of the API, but I put together a utility class in <a href="http://code.google.com/p/jfxtras/">JFXtras</a> called WindowHelper that works around this issue.
<ul>
<li>Note: if there is anything you need to do directly on a Window class, raise it to the JavaFX team so they can make sure it gets added in a future release.</li>
</ul>
</li>
</ul>
<h2>Where did my class go?</h2>
<p>There were a lot of package name changes, and while you can probably dig around in the API docs and find most of what you want, it is good to have an idea about the main changes.</p>
<p>Here is a quick package migration guide:</p>
<table style="border-collapse:collapse;" border="1">
<tbody>
<tr>
<th>Preview Package</th>
<th>1.0 Package</th>
</tr>
<tr>
<td>javafx.application.*</td>
<td>javafx.stage.*</td>
</tr>
<tr>
<td>javafx.scene.geometry.*</td>
<td>javafx.scene.shape.*</td>
</tr>
<tr>
<td>javafx.input.*</td>
<td>javafx.scene.input.*</td>
</tr>
<tr>
<td>javafx.lang.Sequences</td>
<td>javafx.util.Sequences</td>
</tr>
</tbody>
</table>
<h2>API Changes</h2>
<p>There are way too many API changes to hit everything, but here are a few that are common or relatively hard to track down:</p>
<p>Swing changes:</p>
<ul>
<li>Swing classes extend Node, no need for ComponentView</li>
<li>All the Swing class names have &#8220;Swing&#8221; appended in front (e.g. Slider is now SwingSlider)</li>
<li>No more containers or layouts (see the omissions section below)</li>
<li>Wrapping a Swing component is now accomplished via SwingComponent.wrap()</li>
</ul>
<p>Graphics:</p>
<ul>
<li>Horizontal/VerticalAlignment are gone, use a translation with a bind expression instead</li>
<li>FontStyle is gone and replace by properties on the Font class</li>
<li>Number is used almost everywhere now rather than Integer</li>
</ul>
<p>Animation:</p>
<ul>
<li>The start() method has been renamed to play()</li>
<li>autoReverse vs. rate &#8211; Previously, the only way to reverse an animation on subsequent runs was to set autoReverse to true.  Now you can (and have to) use rate to control the direction of the animation by setting it to 1 for forward and -1 for backward.</li>
</ul>
<p>Getters replaced by vars:</p>
<ul>
<li>MouseEvent.getButton() -&gt; MouseEvent.button</li>
<li>MouseEvent.getStageX() -&gt; MouseEvent.sceneX</li>
<li>Node.getWidth() -&gt; Node.boundsInLocal.width</li>
<li>etc.</li>
</ul>
<p>Miscellaneous:</p>
<ul>
<li>__ARG__ -&gt; FX.getArguments()</li>
<li>System.out.println -&gt; println() (builtin)</li>
<li>System.exit(0) -&gt; FX.exit()</li>
<li>DeferredTask -&gt; FX.deferAction()</li>
</ul>
<p>Some noticable omissions include:</p>
<ul>
<li>Dialogs &#8211; SwingDialog is gone and there is no equivalent yet.  Fortunately, I did the hard work and hacked a Dialog replacement (that extends Stage) which you can get as part of the <a href="http://code.google.com/p/jfxtras/">JFXtras project</a>.  It includes support for parent windows, modality, alwaysOnTop, and even auto-size via a &#8220;pack&#8221; option.</li>
<li>Layout &#8211; ClusterPanel and the rest of the Swing containers are gone.  The only layout classes that ship as a part of the 1.0 release are HBox and VBox, which are useful, but not nearly enough.  Until they release some official layouts, there is a Node-based Grid layout implementation in the <a href="http://code.google.com/p/jfxtras/">JFXtras project</a>.</li>
</ul>
<h2>New and Noteworthy</h2>
<ul>
<li>Reflection &#8211; The new JavaFX reflection APIs are very powerful.  They are not for the faint of heart, and have minimal documentation, so this may be a good future blog item.</li>
<li>CSS Styling &#8211; The new CSS styling support will help bridge the gap between designers and coders.  Same comment about lack of documentation, but it is fairly intuitive once you start using it.</li>
<li>Transitions &#8211; There is a whole new transitions package that makes it even easier to do common animations.  Give it a try!</li>
</ul>
<h2>In Summary</h2>
<p>I still have nightmares about painstakingly going through thousands of compilation errors in my code.  Just when I thought I had caught the last one, another few files started compiling and I was buried all over again.  Hopefully through my trial-and-error you will save a few sleepless nights.</p>
<p>Did I catch everything?  Hell no!  But this should be enough help you to get over that initial adoption hump.</p>
<p>Good luck!</p>
<div class="plus-one-wrap"><g:plusone href="http://javafx.steveonjava.com/migrating-from-the-javafx-preview-release/"></g:plusone></div><div style="clear:both;">&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://javafx.steveonjava.com/migrating-from-the-javafx-preview-release/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

