<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>JavaFX News, Demos and Insight // FX Experience</title>
	
	<link>http://fxexperience.com</link>
	<description>Sharing the Experience of JavaFX</description>
	<lastBuildDate>Sun, 25 Jul 2010 22:21:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/fxexperience" /><feedburner:info uri="fxexperience" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>JavaFX links of the week, July 26</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/Nf-CGWuE9sE/</link>
		<comments>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-26/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 22:21:18 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=966</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/javafx-links-of-the-week-july-26/';
var dzone_title = 'JavaFX links of the week, July 26';
var dzone_blurb = 'Another week, another bunch of good links right across the JavaFX ecosystem. Let&#8217;s dive right into the links of the week!I posted an example of how to create a ListView in JavaFX that supports multiple selection.dooApp posted an introduction to...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
Another week, another bunch of good links right across the JavaFX ecosystem. Let&#8217;s dive right into the links of the week!

I posted an example of how to create a ListView in JavaFX that supports multiple selection.
dooApp posted an introduction to their FXForm project. FXForm is a library providing automatic form generation for JavaFX objects.
Carl Dea [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/javafx-links-of-the-week-july-26/';
var dzone_title = 'JavaFX links of the week, July 26';
var dzone_blurb = 'Another week, another bunch of good links right across the JavaFX ecosystem. Let&#8217;s dive right into the links of the week!I posted an example of how to create a ListView in JavaFX that supports multiple selection.dooApp posted an introduction to...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>Another week, another bunch of good links right across the JavaFX ecosystem. Let&#8217;s dive right into the links of the week!</p>
<ul>
<li>I posted an example of how to create a <a href="http://fxexperience.com/2010/07/listview-multiple-selection/">ListView in JavaFX that supports multiple selection</a>.</li>
<li><strong>dooApp</strong> posted an <a href="http://blog.dooapp.com/dude-where-is-my-form">introduction</a> to their <a href="http://bitbucket.org/dooapp/fxform/wiki/Home">FXForm project</a>. FXForm is a library providing automatic form generation for JavaFX objects.</li>
<li><strong>Carl Dea</strong> has published a <a href="http://carlfx.wordpress.com/2010/07/21/javafx-tabbed-pane-tab-panel/">JavaFX Tabbed Pane and Tab Panel</a> prototype.</li>
<li><strong>Sébastien Stormacq</strong> has posted about <a href="http://www.stormacq.com/?p=362">creating an animated chart in JavaFX</a>.</li>
<li><strong>Srikanth Shenoy</strong> continues with the third part of his series titled &#8216;Effective JavaFX Architecture&#8217;. This week his post looks at &#8216;<a href="http://weblogs.java.net/blog/srikanth/archive/2010/07/22/effective-javafx-architecture-part-3-asynchronous-calls-command-pat">Asynchronous calls, Command Pattern and Testability</a>&#8216;.</li>
<li>As part of his series of posts, <strong>Srikanth</strong> has also been creating a JavaFX project called <a href="https://fxobjects.dev.java.net/">fxobjects</a>. From the website, &#8220;FxObjects is a JavaFX Application Framework that enables methodical,  pattern based and test friendly way of developing JavaFX applications  based on ideas and best practices distilled from real life usage&#8221;.</li>
<li>Due to the amount of echoing going on about JavaFX and it&#8217;s future, most of which consist of references to each other (with very little further information), I&#8217;ve picked out <strong>Max Katz&#8217;s</strong> post this week as the only one I&#8217;m including. His post discusses <a href="http://mkblog.exadel.com/ria/javafx-ria/javafx-does-it-have-a-future/">what he believes the future of JavaFX looks like</a>, both the good and the bad points.</li>
</ul>
<p>So,  in general, a week of impressive links, with some new releases, and  interesting discussions and demonstrations. Keep it up folks, and I&#8217;ll  catch you all again in a weeks time.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">Sébastien Stormacq</div>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/Nf-CGWuE9sE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-26/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-26/</feedburner:origLink></item>
		<item>
		<title>ListView Multiple Selection</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/lNJxmXHpFI4/</link>
		<comments>http://fxexperience.com/2010/07/listview-multiple-selection/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 07:11:55 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Controls]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=948</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/listview-multiple-selection/';
var dzone_title = 'ListView Multiple Selection';
var dzone_blurb = 'One of the things that would be really nice to have in the virtualised ListView and TreeView JavaFX controls, not to mention future controls like TableView, is multiple selection. Certain kinds of apps just can not exist without multiple selection in...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
One of the things that would be really nice to have in the virtualised ListView and TreeView JavaFX controls, not to mention future controls like TableView, is multiple selection. Certain kinds of apps just can not exist without multiple selection in fact.
So, unsurprisingly, today I got an email from a user of JavaFX, who claims [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/listview-multiple-selection/';
var dzone_title = 'ListView Multiple Selection';
var dzone_blurb = 'One of the things that would be really nice to have in the virtualised ListView and TreeView JavaFX controls, not to mention future controls like TableView, is multiple selection. Certain kinds of apps just can not exist without multiple selection in...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>One of the things that would be really nice to have in the virtualised ListView and TreeView JavaFX controls, not to mention future controls like TableView, is multiple selection. Certain kinds of apps just can not exist without multiple selection in fact.</p>
<p>So, unsurprisingly, today I got an email from a user of JavaFX, who claims to be a fan of FX Experience (hi Keith!), who was needing multiple selection for his work. I didn&#8217;t actually think it could be done very easily (and one of my main jobs is working on these controls, so I should know), but I spent a bit of time looking into it, and it turns out that it&#8217;s actually quite possible, with a number of warnings and rough edges, and also the use of a little bit of unpublished API. As long as you&#8217;re promising to not tell anyone, I thought I&#8217;d share this code&#8230;.but just with you, so shhh <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><span id="more-948"></span></p>
<p>What I present to you today therefore is to be considered <strong>proof of concept only</strong>. Using this in your day job is considered risky, as some of the code may not work in future releases. Being a proof of concept, the code below is not fully implemented (which I&#8217;ll detail more shortly), and performance may degrade somewhat as the number of selected items increases. No attempt at performance optimisation has been made. Proceed at your own risk <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  I hope that I&#8217;ve sufficiently scared you.</p>
<p>I wanted to briefly show the code, and then just provide you with a jar file to download and use in your own projects. Firstly though, here&#8217;s a screenshot I sent to Keith to detail what he should expect to see when he runs the new control:</p>
<p><img class="aligncenter size-full wp-image-949" title="listview-multiselect" src="http://fxexperience.com/wp-content/uploads/2010/07/listview-multiselect.png" alt="listview-multiselect" width="359" height="301" /></p>
<p>Do not adjust your TV sets (for those of you, ah, accessing the net via your TV?). The ListView on the right looks odd because the label is rotated inside the cell, to make it apparent that you can get multiple selection even when using a custom cell factory. To get the multiple rows selected I just held down ctrl or shift as I left-clicked, as is usually the case in list controls in other UI toolkits. Here&#8217;s the code I wrote to create the app in the screenshot above:</p>
<pre class="brush: javafx;">
Stage {
    title: &quot;Multiple Selection Demo&quot;
    scene: Scene {
        width: 340
        height: 260
        content: [
            HBox {
                spacing: 10
                content: [
                    MultiSelectListView {
                        items: [1..100]
                    },

                    MultiSelectListView {
                        items: [1..100]
                        cellFactory: function() {
                            def cell:ListCell = MultiSelectListCell {
                                node: Label {
                                    rotate: 180
                                    text: bind if (cell.item == null)
                                        then &quot;&quot; else &quot;{cell.item}&quot;;
                                }
                            }
                        }
                    }
                ]
            }
        ]
    }
}
</pre>
<p>Pretty much the kind of code you&#8217;d expect to see when creating a ListView, except the control is called MultiSelectListView, and the ListCell used in the second list is called MultiSelectListCell.</p>
<p>The code for MultiSelectListView is shown below. There is nothing special in here, it simply extends ListView, and adds a bit more API for selectedIndexes and selectedItems, as well as a default cell factory if one isn&#8217;t specified by the user.</p>
<pre class="brush: javafx;">
import javafx.scene.control.ListView;
import javafx.scene.control.ListCell;
import javafx.scene.Node;
import javafx.scene.control.Label;

public class MultiSelectListView extends ListView {

    public-read var selectedItems:Object[];

    public var selectedIndexes:Integer[] on replace {
        selectedItems = for (i in selectedIndexes) items[i];
    }

    override var cellFactory = function():ListCell {
        var label:Label;
        def cell:ListCell = MultiSelectListCell {
            onUpdate: function() {
                def item = cell.item;
                if (item == null) {
                    cell.node = null;
                } else if (item instanceof Node) {
                    cell.node = item as Node;
                } else {
                    if (label == null) {
                        label = Label { }
                    }
                    label.text = if (item instanceof String) then item as String else &quot;{item}&quot;;
                    if (cell.node != label) cell.node = label;
                }
            }
        }
    }
}
</pre>
<p>Moving on, we come to MultiSelectListCell, which is where the real warning comes &#8211; this class has unpublished API being used, and we offer no guarantee that it&#8217;ll stay this way. Use it at your own risk, and seriously, don&#8217;t build your business around this API being available. You&#8217;ve been warned. </p>
<p>This class creates a custom MultiSelectListCellSkin, and binds to the selectedIndexes sequence to determine if it is selected or not. When this property changes, it calls some impl_ code to re-evaluate its state, to allow for the background selection colour to be turned on or off as necessary. The rest of the code is pretty straightforward (i.e. don&#8217;t question it) <img src='http://fxexperience.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<pre class="brush: javafx;">
import javafx.scene.control.ListCell;
import javafx.scene.control.Skin;
import com.sun.javafx.scene.control.skin.ListCellSkin;
import com.sun.javafx.scene.control.skin.SkinAdapter;
import javafx.util.Sequences;

public class MultiSelectListCell extends ListCell {

    def multiSelected = bind Sequences.indexOf((listView as MultiSelectListView).selectedIndexes, index) != -1 on invalidate {
        impl_pseudoClassStateChanged(&quot;selected&quot;);
    }

    package override function createDefaultSkin():Skin {
        SkinAdapter {
            rootRegion: MultiSelectListCellSkin { }
        }
    }

    override function impl_getPseudoClassState():String[] {
        [
            if (multiSelected) &quot;selected&quot; else null,
            super.impl_getPseudoClassState()
        ]
    }
}
</pre>
<p>MultiSelectListCellSkin is hidden inside MultiSelectListCell (for no particular reason), and its job is simply to just extend ListCellSkin, apply a small bug workaround, and apply a custom behavior, which is where the actual multiple selection magic happens.</p>
<pre class="brush: javafx;">
class MultiSelectListCellSkin extends ListCellSkin {
    override var behavior = MultiSelectListCellBehavior { }

    postinit {
        // This fixes an issue where the mouseReleased function is called twice.
        overlay.onMouseReleased = null;
    }
}
</pre>
<p>The final class is a slight extension of the ListCellBehavior class, not surprisingly called MultiSelectListCellBehavior. This class handles the mouse click event, including determining if ctrl or shift is held down, and acting appropriately.</p>
<pre class="brush: javafx;">
import com.sun.javafx.scene.control.behavior.ListCellBehavior;
import javafx.util.Sequences;

public class MultiSelectListCellBehavior extends ListCellBehavior {

    override function mouseReleased(e) {
        // Note that list.select will reset selection
        // for out of bounds indexes. So, need to check
        def listCell = skin.control as MultiSelectListCell;
        def listView = listCell.listView as MultiSelectListView;

        // If the mouse event is not contained within this ListCell, then
        // we don't want to react to it.
        if (listCell.contains(e.x, e.y)) {
            if (listCell.index &gt;= sizeof listView.items) return;

            var row = listCell.index;

            if (e.controlDown) {
                if (Sequences.indexOf(listView.selectedIndexes, row) == -1) {
                    insert row into listView.selectedIndexes;
                } else {
                    delete row from listView.selectedIndexes;
                }
            } else if (e.shiftDown) {
                var start = listView.focusedIndex;
                var end = row;
                var range = if (start &lt; end)
                    then [start..end] else [end..start];

                listView.selectedIndexes = range;
            } else {
                delete listView.selectedIndexes;
                insert row into listView.selectedIndexes;
                listView.focus(row);
            }
        }
    }
}
</pre>
<p>That&#8217;s all there is to it. Note that whilst I wrote this, because it is not a &#8216;production-quality&#8217; control, I haven&#8217;t tested it at all, past a few user tests. I&#8217;m sure it&#8217;ll have issues. If you report them to me I&#8217;ll revise this post to ensure the best control we can have. You should also note that this in no way reflects how we&#8217;ll do multiple selection in the future, when it is supported &#8216;natively&#8217;.</p>
<p>Now, on to the warnings I warned you were coming. In general, don&#8217;t use the select() function any more &#8211; just directly manipulate the selectedIndexes sequence. Also, don&#8217;t use the selectedItem / selectedIndex properties any more &#8211; just use the selectedItems and selectedIndexes sequences instead. If you think you&#8217;re going to forget this, it should be possible to just keep overriding more functions / properties to have everything work as expected, but unless I feel sufficiently nagged, I&#8217;ll probably just leave this as a user exercise. Similarly, there is no support for keyboard navigation / multiple selection in this version.</p>
<p>So &#8211; that&#8217;s it really. You can download a <a href="http://www.jonathangiles.net/javafx/ListMultipleSelection.zip">NetBeans project containing this source code</a>, or if you&#8217;re just wanting to use the code as-is, I&#8217;ve also <a href="http://www.jonathangiles.net/javafx/ListMultipleSelection.jar">put up a jar file</a> for you to use directly in your own applications. Feel free to leave comments.</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/lNJxmXHpFI4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/07/listview-multiple-selection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/07/listview-multiple-selection/</feedburner:origLink></item>
		<item>
		<title>JavaFX links of the week, July 19</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/RUjNgA0xgl0/</link>
		<comments>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-19/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 22:40:44 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=944</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/javafx-links-of-the-week-july-19/';
var dzone_title = 'JavaFX links of the week, July 19';
var dzone_blurb = 'Well, what an interesting week we had in the JavaFX world. It started  off with Kirill Grouchnikov posting his thoughts that JavaFX is a train wreck.  This created a number of threads around the web discussing this. At the  same time Stephen Chin posted...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
Well, what an interesting week we had in the JavaFX world. It started  off with Kirill Grouchnikov posting his thoughts that JavaFX is a train wreck.  This created a number of threads around the web discussing this. At the  same time Stephen Chin posted his petition to open source  JavaFX. So [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/javafx-links-of-the-week-july-19/';
var dzone_title = 'JavaFX links of the week, July 19';
var dzone_blurb = 'Well, what an interesting week we had in the JavaFX world. It started  off with Kirill Grouchnikov posting his thoughts that JavaFX is a train wreck.  This created a number of threads around the web discussing this. At the  same time Stephen Chin posted...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>Well, what an interesting week we had in the JavaFX world. It started  off with <strong>Kirill Grouchnikov</strong> posting his thoughts that <a href="http://www.pushing-pixels.org/?p=2106">JavaFX is a train wreck</a>.  This created a number of threads around the web discussing this. At the  same time <strong>Stephen Chin</strong> posted his <a href="http://steveonjava.com/javafx-petition/">petition to open source  JavaFX</a>. So much controversy, so many (sometimes anonymous) comments &#8211;  what a week! For what it&#8217;s worth, I&#8217;m just reporting the news here, not  endorsing or disagreeing with any of it <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<ul>
<li>As mentioned, this week <strong>Kirill Grouchnikov</strong> outlined his  thinking that <a href="http://www.pushing-pixels.org/?p=2106">JavaFX is a train wreck</a>.  Quite quickly the comments on his blog became incredibly side-tracked,  so he turned off comments. Because of the nature of the topic, the  discussion <a href="http://java.dzone.com/polls/how-can-oracle-make-javafx">spilled</a> <a href="http://www.javaworld.com/community/node/4647">over</a> into a  number of other blogs, and for the most part was mostly negative.</li>
<li><strong>Stephen  Chin</strong> has posted a petition to <a href="http://steveonjava.com/javafx-petition/">open source JavaFX</a>.  Further discussion is available <a href="http://java.dzone.com/articles/stephen-chins-petition-open">here</a> and <a href="http://groups.google.com/group/javaposse/browse_thread/thread/5b602839dd2c836c">here</a>.</li>
<li>The  next <a href="http://www.svjugfx.org/">Silicon Valley JavaFX Users Group</a> topic has been announced: it&#8217;ll be <strong>Stephen Chin</strong> and <strong>Keith  Combs</strong> doing a live lab session where they will demonstrate the <a href="http://www.svjugfx.org/calendar/13784815/?eventId=13784815&amp;action=detail">concepts  behind implementing JavaFX Controls</a>. It&#8217;s coming up August 11, so a  few weeks away yet.</li>
<li><strong>Jim Weaver</strong> has posted a tutorial  on the Sun Developer Network titled &#8220;<a href="http://java.sun.com/developer/technicalArticles/javafx/css/">Stylin&#8217;  with JavaFX</a>&#8220;.</li>
<li><strong>Dean Iverson</strong> has posted some <a href="http://pleasingsoftware.blogspot.com/2010/07/my-bads.html">comments  about his previous blog posts</a> to fix up mistakes and  misunderstandings on his part.</li>
<li>Max Katz has done a bunch of blogs recently, titled &#8216;<a href="http://mkblog.exadel.com/ria/javafx-ria/binding-to-server-side-context-variable-from-javafx/">Binding  to server-side context variable from JavaFX</a>&#8216;, &#8216;<a href="http://mkblog.exadel.com/ria/javafx-ria/using-expression-language-el-in-javafx-to-communicate-with-server/">Using  Expression Language (EL) in JavaFX to communicate with server</a>&#8216; and &#8216;<a href="http://mkblog.exadel.com/ria/javafx-ria/seam-conversation-from-javafx/">Seam  conversations from JavaFX</a>&#8216;.</li>
<li><strong>Alex Ruiz</strong> has announced <a href="http://alexruiz.developerblogs.com/?p=1371">FEST JavaFX Compiler  Maven Plug-in 1.0b2</a>. This release adds new configuration options.</li>
<li><strong>Sergey  Malenkov</strong> has posted about &#8216;<a href="http://weblogs.java.net/blog/malenkov/archive/2010/07/09/localized-reaction-time">localized  reaction time</a>&#8216;. It shows how you can localise your application in  JavaFX.</li>
<li><strong>William Antônio Siqueira</strong> has created <a href="http://fxapps.blogspot.com/2010/07/searching-lyrics-with-this-javafx-app.html">LyricSearchFX</a>,  which you can run over at his <a href="http://fxapps.blogspot.com/">new blog</a>.</li>
<li>I posted <a href="http://jonathangiles.net/javafx/TabView/demo/1/">two</a> <a href="http://jonathangiles.net/javafx/TabView/demo/2/">brief</a> screencasts to show off a TabView control I&#8217;m building in my spare time.</li>
</ul>
<p>Whew! What a week. Catch you all again in  a week.</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/RUjNgA0xgl0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-19/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-19/</feedburner:origLink></item>
		<item>
		<title>JavaFX links of the week, July 12</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/QQ2ofvSkU4A/</link>
		<comments>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-12/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 22:02:16 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=942</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/javafx-links-of-the-week-july-12/';
var dzone_title = 'JavaFX links of the week, July 12';
var dzone_blurb = 'A good week of JavaFX links this week &#8211; some exciting releases,  and interesting blog posts exploring / announcing interesting work.  Let&#8217;s get right into it!Richard Bair posted a text  alignment trick that is useful when trying to lay out...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
A good week of JavaFX links this week &#8211; some exciting releases,  and interesting blog posts exploring / announcing interesting work.  Let&#8217;s get right into it!

Richard Bair posted a text  alignment trick that is useful when trying to lay out Label text.
I posted a tip regarding sequence  performance, and how you [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/javafx-links-of-the-week-july-12/';
var dzone_title = 'JavaFX links of the week, July 12';
var dzone_blurb = 'A good week of JavaFX links this week &#8211; some exciting releases,  and interesting blog posts exploring / announcing interesting work.  Let&#8217;s get right into it!Richard Bair posted a text  alignment trick that is useful when trying to lay out...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>A good week of JavaFX links this week &#8211; some exciting releases,  and interesting blog posts exploring / announcing interesting work.  Let&#8217;s get right into it!</p>
<ul>
<li><strong>Richard Bair</strong> posted a <a href="http://fxexperience.com/2010/07/text-alignment-trick/">text  alignment trick</a> that is useful when trying to lay out Label text.</li>
<li>I posted a tip regarding <a href="http://fxexperience.com/2010/07/sequences-performance-tip/">sequence  performance</a>, and how you can cut down on needless churn.</li>
<li><strong>Stephen Chin</strong> has announced the <a href="http://groups.google.com/group/jfxtras-users/browse_thread/thread/8c4762b7037a8861">release  of JFXtras 0.7 release candidate 2</a>.</li>
<li><strong>Max Katz</strong> is presenting at the next <a href="http://mkblog.exadel.com/events/presenting-at-silicon-valley-javafx-user-group-enterprise-javafx/">Silicon  Valley JavaFX Users Group meetup</a>, which is this coming week on  Wednesday, July 14, 2010 at 7PM PST.</li>
<li>Speaking of <strong>Max</strong>, he has posted two blog posts titled &#8216;<a href="http://mkblog.exadel.com/ria/javafx-ria/calling-seam-component-from-javafx-2/">Calling  Seam component from JavaFX</a>&#8216; and &#8216;<a href="http://mkblog.exadel.com/ria/javafx-ria/invoking-hibernate-validator-from-javafx/">Invoking  Hibernate Validator from JavaFX</a>&#8216;.</li>
<li>It looks like IntelliJ IDEA is starting to support JavaFX even more,  with the <a href="http://plugins.jetbrains.net/plugin/?idea&amp;id=5004">0.2  release of their JavaFX plugin for IntelliJ</a>. <a href="http://www.youtube.com/watch?v=Pcx_l-xhK4A&amp;hd=1">Watch the  Getting Started video</a> if you&#8217;re interested.</li>
<li><strong>Nicholas</strong> has blogged about <a href="http://smithnicholas.wordpress.com/2010/07/07/displaying-a-javafx-applet-in-a-grails-application/">displaying  a JavaFX applet in a Grails application</a>.</li>
<li><strong>Srikanth Shenoy</strong> has posted the second part of his multi-part  series on &#8216;Effective JavaFX Architecture&#8217;, this time covering <a href="http://weblogs.java.net/blog/srikanth/archive/2010/07/07/effective-javafx-architecture-part-2-test-driven-development-tdd-ja">Test  Driven Development with JavaFX</a>.</li>
</ul>
<p>That&#8217;s us for another week. Thanks to everyone for your hard  work in the community, and for sharing your knowledge with the rest of  us <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Catch you all again in a weeks time!</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/QQ2ofvSkU4A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-12/</feedburner:origLink></item>
		<item>
		<title>Sequences Performance Tip</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/MT0mfis4hO8/</link>
		<comments>http://fxexperience.com/2010/07/sequences-performance-tip/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 01:43:54 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Language Lesson]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=905</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/sequences-performance-tip/';
var dzone_title = 'Sequences Performance Tip';
var dzone_blurb = 'Sure, there are plenty of tips discussing how to use sequences in JavaFX, but the one I wanted to cover quickly today is regarding the fact that sequences are immutable. That is, once you create them, their content can&#8217;t change.&#8216;You lie!&#8216;...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
Sure, there are plenty of tips discussing how to use sequences in JavaFX, but the one I wanted to cover quickly today is regarding the fact that sequences are immutable. That is, once you create them, their content can&#8217;t change.
&#8216;You lie!&#8216; I hear you all shout, running off to your IDE&#8217;s to show me the [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/sequences-performance-tip/';
var dzone_title = 'Sequences Performance Tip';
var dzone_blurb = 'Sure, there are plenty of tips discussing how to use sequences in JavaFX, but the one I wanted to cover quickly today is regarding the fact that sequences are immutable. That is, once you create them, their content can&#8217;t change.&#8216;You lie!&#8216;...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>Sure, there are <a href="http://java.sun.com/javafx/1/tutorials/core/sequences/">plenty of tips</a> discussing how to use sequences in JavaFX, but the one I wanted to cover quickly today is regarding the fact that sequences are <strong>immutable</strong>. That is, once you create them, their content can&#8217;t change.</p>
<p>&#8216;<em>You lie!</em>&#8216; I hear you all shout, running off to your IDE&#8217;s to show me the following fully legal and compiler-friendly code:</p>
<pre class="brush: javafx;">
var seq = [ 1, 2, 3 ];
insert 4 into seq;
insert 5 into seq;
delete 1 from seq;

println(seq);
</pre>
<p>If you run this code, the output will be <code>[ 2, 3, 4, 5 ]</code>, as expected. It&#8217;s understandable if you think the sequence is being updated in-place &#8211; it certainly looks that way from where we&#8217;re all standing &#8211; except that under the hood it isn&#8217;t, and there are performance implications we need to be clear on. To get straight to the point, the insert and delete instructions create a brand new sequence instance, but fortunately they also ensure that the seq variable always refers to the new instance, quietly leaving the old instance to get garbage collected.</p>
<p>Of course, as I just noted, from a developers perspective we can treat seq as a reference to a sequence instance and be oblivious to these &#8216;behind-the-scenes&#8217; sequence shenanigans. There is nothing wrong with this, but it&#8217;s important to know that creating sequences isn&#8217;t free, and certainly minimising the amount of sequences we create is a smart idea.</p>
<p>To be slightly more technical, I should note that there are some exceptions to this &#8217;sequences are immutable&#8217; rule when dealing with non-shared sequences of specific types, but I don&#8217;t want to muddy the point of this blog, which is&#8230;.</p>
<p><strong>Use the expression language features of JavaFX to reduce the number of sequence instances you need to create.</strong></p>
<p>For example, you might have code that looks like the following:</p>
<pre class="brush: javafx;">
var seq:Integer[];

for (i in [1..MAX]) {
    insert i*i into seq;
}
</pre>
<p>I hope, with this blog post firmly at the forefront of your mind, you can now see why perhaps this isn&#8217;t such a great idea: <strong>we&#8217;re creating <code>MAX</code> sequence instances</strong>, one for each iteration of the <code>for</code> loop &#8211; ouch. Importantly, this example isn&#8217;t far-fetched and made to prove a point: I just found a very similar example in my code the other day (which I promptly fixed up), and even found a few blog posts on this site and other sites that use this approach. What you actually should do is something like the following:</p>
<pre class="brush: javafx;">
var seq:Integer[];

seq = for (i in [1..MAX]) {
    i*i
}
</pre>
<p>In this case rather than create <code>MAX</code> instances of the sequence, we&#8217;re creating only one &#8211; the result of the <code>for</code> expression. This is considerably more efficient, and can lead to huge performance gains, depending on what you&#8217;re doing. In my case it made the difference between my code being usable and being jittery. Obviously in my case this was a very critical <code>for</code> loop, and it may be similar in your use cases also.</p>
<p>I hope that this helps you eek out a little more performance from your apps. Now, go forth and optimise your sequences <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/MT0mfis4hO8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/07/sequences-performance-tip/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/07/sequences-performance-tip/</feedburner:origLink></item>
		<item>
		<title>Text “Alignment” Trick</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/KLv7yux8L_s/</link>
		<comments>http://fxexperience.com/2010/07/text-alignment-trick/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 21:52:42 +0000</pubDate>
		<dc:creator>Richard Bair</dc:creator>
				<category><![CDATA[Tips n' Tricks]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=903</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/text-alignment-trick/';
var dzone_title = 'Text &#8220;Alignment&#8221; Trick';
var dzone_blurb = 'One of the annoying sharp edges in JavaFX is around text alignment, especially with regards to the Text node. In this tip, I&#8217;m going to skip using the Text node in favor of using the Label control, because it gives you better&#8230; uh&#8230; control...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
One of the annoying sharp edges in JavaFX is around text alignment, especially with regards to the Text node. In this tip, I&#8217;m going to skip using the Text node in favor of using the Label control, because it gives you better&#8230; uh&#8230; control over text placement. This is actually based on a trick I [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/text-alignment-trick/';
var dzone_title = 'Text &#8220;Alignment&#8221; Trick';
var dzone_blurb = 'One of the annoying sharp edges in JavaFX is around text alignment, especially with regards to the Text node. In this tip, I&#8217;m going to skip using the Text node in favor of using the Label control, because it gives you better&#8230; uh&#8230; control...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>One of the annoying sharp edges in JavaFX is around text alignment, especially with regards to the Text node. In this tip, I&#8217;m going to skip using the Text node in favor of using the Label control, because it gives you better&#8230; uh&#8230; control over text placement. This is actually based on a trick I used to use with Swing all the time. If I wanted to center some text in a layout, I&#8217;d specify the space I wanted the text positioned within by setting the size of the label to match that space, and then I&#8217;d either position the text at the center, top, right, etc.</p>
<p>Using the same trick in JavaFX, I can cause some text to be right positioned. An additional benefit to using the Label control is that if the space isn&#8217;t big enough for the text, it can be elided using the textOverrun variable.</p>
<pre class="brush: javafx;">
    Label {
        width: bind 120
        text: &quot;Right Positioned Message!&quot;
        font: Font { size: 10 }
        textFill: Color.BLACK
        hpos: HPos.RIGHT
    }
</pre>
<p>Anyway, it ain&#8217;t perfect but a good trick for the moment.</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/KLv7yux8L_s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/07/text-alignment-trick/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/07/text-alignment-trick/</feedburner:origLink></item>
		<item>
		<title>JavaFX links of the week, July 5</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/INRsb3YWNuA/</link>
		<comments>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-5/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 22:35:05 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=901</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/javafx-links-of-the-week-july-5/';
var dzone_title = 'JavaFX links of the week, July 5';
var dzone_blurb = 'Wow, July already. Time sure is flying these days. As always, please feel free to flick  me an email or a tweet to let me know of  any news you want included. Let&#8217;s get on with the news!Tor Norbye blogged about not  using implicit return types in...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
Wow, July already. Time sure is flying these days. As always, please feel free to flick  me an email or a tweet to let me know of  any news you want included. Let&#8217;s get on with the news!

Tor Norbye blogged about not  using implicit return types in public API declarations in  [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/07/javafx-links-of-the-week-july-5/';
var dzone_title = 'JavaFX links of the week, July 5';
var dzone_blurb = 'Wow, July already. Time sure is flying these days. As always, please feel free to flick  me an email or a tweet to let me know of  any news you want included. Let&#8217;s get on with the news!Tor Norbye blogged about not  using implicit return types in...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>Wow, July already. Time sure is flying these days. As always, please feel free to flick  me an <a href="mailto:jonathan@jonathangiles.net">email</a> or a <a href="http://www.twitter.com/JonathanGiles">tweet</a> to let me know of  any news you want included. Let&#8217;s get on with the news!</p>
<ul>
<li><strong>Tor Norbye</strong> blogged about <a href="http://blogs.sun.com/tor/entry/don_t_use_implicit_return">not  using implicit return types</a> in <span style="text-decoration: underline;">public API declarations</span> in  JavaFX, and from my perspective, copped quite an unfair bashing for  doing so. He also provided a NetBeans plugin for identifying this issue,  and &#8216;quick fixing&#8217; it. As for the comments on the post: I personally  love implicit typing, but <strong>not</strong> when it is public API, for the  reasons Tor identifies. It would suck to have to type :Void for every  function and specify the type of all parameters in an overridden  function. The  language really isn&#8217;t broken.</li>
<li>The <strong>Exadel</strong> JavaFX  Plugin for Eclipse has been <a href="http://mkblog.exadel.com/ria/javafx-ria/exadel-javafx-plug-in-for-eclipse-version-1-3-3/">upgraded  to 1.3.3</a>. In addition to this they&#8217;ve blogged about the <a href="http://mkblog.exadel.com/ria/javafx-ria/exadel-javafx-plug-in-for-eclipse-go-to-member-feature-in-pictures/">new  &#8216;go to member&#8217; feature</a> added in 1.3.3.</li>
<li><strong>Johannes  Schneider</strong> has announced that he has <a href="http://blog.cedarsoft.com/2010/07/javafx2java-bridge-added-to-jfxtras-step-1/">added  his JavaFX2Java bridge to the JFXtras project</a> (in a separate cloned  repo). You can <a href="http://blog.cedarsoft.com/2010/05/closing-the-gap-between-java-and-javafx/">find  out more about this bridge</a> in another blog posting.</li>
<li>The <strong>Oracle  Technical Network</strong> <a href="http://medianetwork.oracle.com/media/show/15301">interviewed John  Jullion-Ceccarelli and Martin Ryzl</a>, two of the managers behind  NetBeans 6.9. They discussed the new NetBeans Composer tool for rapid  JavaFX application development.</li>
<li><strong>Srikanth Shenoy</strong> has  blogged about &#8216;<a href="http://weblogs.java.net/blog/srikanth/archive/2010/07/01/effective-javafx-architecture-part-1">Effective  JavaFX Architecture</a>&#8216;. This is the first part of a series of posts  he is promising to do.</li>
<li><strong>Eviware</strong> popped out of nowhere this week with their <a href="http://www.loadui.org/">loadUI</a> application for load-testing webapps. They&#8217;ve <a href="http://www.loadui.org/loadUI-Demo-Movies.html">posted some videos</a> and in general their app, built using JavaFX and Groovy, looks really  impressive.</li>
<li><strong>Oracle</strong> announced that <a href="http://www.oracle.com/us/corporate/press/103103">JavaFX is  powering the Major League Baseball &#8216;fantasy baseball&#8217; applications</a>,  although I haven&#8217;t yet seen it in action because I don&#8217;t live in the US  or Canada (<a href="http://mlb.mlb.com/mlb/fantasy/wsfb_c/info/index.jsp">but you can  go here to sign up, and presumably play</a>).</li>
</ul>
<p>That&#8217;s it for another week folks. Catch you  in a weeks time.</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/INRsb3YWNuA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/07/javafx-links-of-the-week-july-5/</feedburner:origLink></item>
		<item>
		<title>JavaFX links of the week, June 28</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/DoibcL-Wb30/</link>
		<comments>http://fxexperience.com/2010/06/javafx-links-of-the-week-june-28/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 20:51:28 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=899</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/06/javafx-links-of-the-week-june-28/';
var dzone_title = 'JavaFX links of the week, June 28';
var dzone_blurb = 'A fairly quiet week in the JavaFX world this week, but  nevermind, I&#8217;m sure it&#8217;s just because the majority of you are too busy  working on your blog masterpieces for next week   Regardless, there  are some very useful links in this weeks post,...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
A fairly quiet week in the JavaFX world this week, but  nevermind, I&#8217;m sure it&#8217;s just because the majority of you are too busy  working on your blog masterpieces for next week   Regardless, there  are some very useful links in this weeks post, so have at it, and as  [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/06/javafx-links-of-the-week-june-28/';
var dzone_title = 'JavaFX links of the week, June 28';
var dzone_blurb = 'A fairly quiet week in the JavaFX world this week, but  nevermind, I&#8217;m sure it&#8217;s just because the majority of you are too busy  working on your blog masterpieces for next week   Regardless, there  are some very useful links in this weeks post,...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>A fairly quiet week in the JavaFX world this week, but  nevermind, I&#8217;m sure it&#8217;s just because the majority of you are too busy  working on your blog masterpieces for next week <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Regardless, there  are some very useful links in this weeks post, so have at it, and as  always please do flick me an <a href="mailto:jonathan@jonathangiles.net">email</a> (or <a href="http://www.twitter.com/JonathanGiles">twitter</a> message) with  any link you think is worthy of being included.</p>
<ul>
<li>There&#8217;s been a bit of a documentation refresh going on recently,  with the <a href="http://java.sun.com/javafx/1.3/docs/api">JavaFX 1.3 API</a> getting refreshed, and a <a href="http://java.sun.com/javafx/1.3/docs/api/javafx.scene/doc-files/cssref.html">JavaFX  CSS reference document</a> being made available at the same time. For  more information check out my <a href="http://fxexperience.com/2010/06/three-useful-javafx-links/">summary  blog post</a>.</li>
<li>I posted about <a href="http://fxexperience.com/2010/06/custom-cell-caching/">caching  in custom cells</a> in JavaFX controls such as ListView and TreeView.  This is (probably) a useful post for people creating custom cells.</li>
<li><strong>Jim Clarke</strong> has blogged about his experimentation with <a href="http://javafxplace.blogspot.com/2010/06/javafx-and-webm-on-linux.html">JavaFX  and WEBM on Linux</a>.</li>
<li><strong>Jan-Hendrik Kuperus</strong> has blogged the second part of his post  on <a href="http://www.jhkuperus.nl/articles/java/javafx/integrating-javafx-with-regular-java-part-2/">integrating  JavaFX with regular Java</a>.</li>
<li>Mark in your calendars July 14th, which is when <strong>Max Katz</strong> is <a href="http://www.svjugfx.org/calendar/13605800/?eventId=13605800&amp;action=detail">talking  about enterprise JavaFX</a>.</li>
<li>Speaking of <strong>Max</strong>, he has also blogged about the <a href="http://mkblog.exadel.com/javafx-plug-in/exadel-javafx-plug-in-for-eclipse-preferences-page-in-pictures/">new  preferences dialog</a> added to the JavaFX Plugin for Eclipse that  Exadel, the company he works for, develops.</li>
</ul>
<p>That&#8217;s all folks. Thanks to everyone who took the time to post about  what they&#8217;re working on, and for those of you who didn&#8217;t, I&#8217;m looking  forward to your blogging masterpieces next week <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/DoibcL-Wb30" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/06/javafx-links-of-the-week-june-28/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/06/javafx-links-of-the-week-june-28/</feedburner:origLink></item>
		<item>
		<title>Custom Cell Caching</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/5Nzb44x2Nt0/</link>
		<comments>http://fxexperience.com/2010/06/custom-cell-caching/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 06:09:23 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[UI Design]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=883</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/06/custom-cell-caching/';
var dzone_title = 'Custom Cell Caching';
var dzone_blurb = 'Ok, I know we&#8217;ve been going on about custom cells / cell factories a bit recently, but I wanted to do one more post about a very useful topic: caching within cell content.These days &#8216;Hello World&#8217; has been replaced by building a Twitter...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
Ok, I know we&#8217;ve been going on about custom cells / cell factories a bit recently, but I wanted to do one more post about a very useful topic: caching within cell content.
These days &#8216;Hello World&#8217; has been replaced by building a Twitter client, so I&#8217;ve decided to frame this topic in terms of building [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/06/custom-cell-caching/';
var dzone_title = 'Custom Cell Caching';
var dzone_blurb = 'Ok, I know we&#8217;ve been going on about custom cells / cell factories a bit recently, but I wanted to do one more post about a very useful topic: caching within cell content.These days &#8216;Hello World&#8217; has been replaced by building a Twitter...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>Ok, I know we&#8217;ve been going on about custom cells / cell factories a bit recently, but I wanted to do one more post about a very useful topic: caching within cell content.</p>
<p>These days &#8216;Hello World&#8217; has been replaced by building a Twitter client, so I&#8217;ve decided to frame this topic in terms of building a Twitter client. Because I don&#8217;t actually care about the whole web service side of thing, I&#8217;ve neglected to implement the whole &#8216;real data&#8217; / web services aspect of it. If you want to see an actual running implementation with real data, have a look at <span>William Antônio&#8217;s <a href="http://bit.ly/cXsqUR">Twitter client</a>, which is using this ListCell implementation.</span></p>
<p><span><span id="more-883"></span>So, in all the posts to this site related to cells, I&#8217;m sure you&#8217;ve probably come to appreciate the ways in which you should create a ListView or TreeView with custom cell factories. Therefore, what I really want to cover in this post is just the custom cell implementation, and the importance of caching. A Twitter client wouldn&#8217;t be a true client without showing the users profile image, so this is my target for caching. Without caching, each time the cell was updated (i.e. the content changes due to scrolling, or when we scroll a user out of screen and then back in), we&#8217;d have to redownload and load the image. This would lead to considerable lag and a poor user experience. What we need to do is load the image once, cache it, and reuse it whenever the image URL is requested by a cell. At the same time, we don&#8217;t want to run the PC dry of memory by loading all profile images into memory. Enter: <a href="http://java.sun.com/javase/6/docs/api/java/lang/ref/SoftReference.html">SoftReference</a> caching.<br />
</span></p>
<p><span><strong>Word of warning</strong>: I&#8217;m not a caching expert. It is possible that I&#8217;ve done something stupid, and I hope you&#8217;ll let me know, but I believe that the code below should at least be decent. I&#8217;ll happily update this example if anyone gives me useful feedback.</span></p>
<p><span>Check out the code below, and I&#8217;ll continue to discuss it afterwards.</span></p>
<pre class="brush: javafx;">
import model.Tweet;

import java.lang.ref.SoftReference;
import java.util.HashMap;

import javafx.geometry.HPos;
import javafx.geometry.VPos;
import javafx.util.Math;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Container;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;

// controls whether the cache is used or not. This _really_ shouldn't be false!
def useCache = true;

// map of String -&gt; SoftReference (of Image)
def map = new HashMap();

def IMAGE_SIZE = 48;

public class TwitterListCell extends ListCell {

    // used to represent the users image
    var imageView:ImageView;

    // a slightly bigger and bolder label for the persons name
    var personName:Label = Label {
        font: Font.font(&quot;Arial&quot;, FontWeight.BOLD, 13);
    }

    // the message label
    var message:Label = Label {
        textWrap: true
    }

    override var node = Container {
        content: bind [ imageView, personName, message ]

        override function getPrefHeight(width:Number):Number {
            def w = listView.width;
            Math.max(IMAGE_SIZE, personName.getPrefHeight(w) + message.getPrefHeight(w));
        }

        override function doLayout():Void {
            var x:Number = -1.5;
            var y:Number = 0;
            var listWidth = listView.width;
            var cellHeight = height;

            // position image
            Container.positionNode(imageView, x, y, IMAGE_SIZE, cellHeight,
                HPos.CENTER, VPos.TOP, false);

            // position text at the same indent position regardless of whether
            // an image exists or not
            x += IMAGE_SIZE + 5;
            var textWidth = listWidth - x;
            var personNameHeight = personName.getPrefHeight(textWidth);
            Container.resizeNode(personName, textWidth, personNameHeight);
            Container.positionNode(personName, x, y, listWidth - x, personNameHeight,
                HPos.LEFT, VPos.TOP, false);

            y += personNameHeight;
            Container.resizeNode(message, textWidth, message.getPrefHeight(textWidth));
            Container.positionNode(message, x, y, listWidth - x, height - personNameHeight,
                HPos.LEFT, VPos.TOP, false);
        }
    }

    override var onUpdate = function():Void {
        var tweet = item as Tweet;

        personName.text = tweet.person.name;
        message.text = tweet.message;

        // image handling
        if (map.containsKey(tweet.person.image)) {
            // the image has possibly been cached, so lets try to get it
            var softRef = map.get(tweet.person.image) as SoftReference;

            // get the image out of the SoftReference wrapper
            var image = softRef.get() as Image;

            // check if it is null - which would be the case if the image had
            // been removed by the garbage collector
            if (image == null) {
                // we need to reload the image
                loadImage(tweet.person.image);
            } else {
                // the image is available, so we can reuse it without the
                // burden of having to download and reload it into memory.
                imageView = ImageView {
                    image: image;
                }
            }
        } else {
            // the image is not cached, so lets load it
            loadImage(tweet.person.image);
        }
    };

    function loadImage(url:String) {
        // create the image and imageview
        var image = Image {
            url: url
            height: IMAGE_SIZE
            preserveRatio: true
            backgroundLoading: true
        }
        imageView = ImageView {
            image: image;
        }

        if (useCache) {
            // put into cache using a SoftReference
            var softRef = new SoftReference(image);
            map.put(url, softRef);
        } else {
            map.remove(url);
        }
    }
}
</pre>
<p><span>You&#8217;ll note that in this example most of the code is pretty standard. A few variables are created for the image and text, and then I&#8217;ve gone the route of laying the content out in a Container, but you can achieve a similar layout using the available layout containers. Following this I have defined an onUpdate function, which is called whenever the cell should be updated. This is usually called due to a user interaction, which may potentially change the Cell.item value, which would of course require an update of the cell&#8217;s visuals.</span></p>
<p><span>The bulk, and most important part, of the onUpdate function deals with loading the users profile image, or retrieving and reusing the cached version of it. Note the use of the global HashMap, which maps between the URL of the users image and the Image itself. Because it is global (i.e. static), this map will be available, and used, by all TwitterListCell instances. Also important to note is that I didn&#8217;t put the ImageView itself into the HashMap as a Node can not be placed in multiple positions in the scenegraph, but an Image can be.</span></p>
<p><span>The rest of the code in this class really just deals with the fact that a SoftReference may clear out it&#8217;s reference to the Image object if the garbage collector needs the memory, in which case we need to reload the image again. The other obvious part is the need to also put the image into the cache if it&#8217;s not already there.</span></p>
<p><span>Shown below is the end result, but remember that there is a working version of this demo in William Antônio&#8217;s <a href="http://bit.ly/cXsqUR">Twitter client</a>, which is a very early work in progress.</span></p>
<p><img src="http://fxexperience.com/wp-content/uploads/2010/06/twitter-listcell1.PNG" alt="twitter-listcell" title="twitter-listcell" width="187" height="366" class="aligncenter size-full wp-image-893" /></p>
<p><span>I hope this might be useful to people, and as always we&#8217;re keen to hear your thoughts and feedback, and what you&#8217;re hoping us to cover. Until next time &#8211; cheers! <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </span></p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/5Nzb44x2Nt0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/06/custom-cell-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/06/custom-cell-caching/</feedburner:origLink></item>
		<item>
		<title>Three Useful JavaFX Links</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/lLAdoB9Br24/</link>
		<comments>http://fxexperience.com/2010/06/three-useful-javafx-links/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 05:15:05 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=881</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/06/three-useful-javafx-links/';
var dzone_title = 'Three Useful JavaFX Links';
var dzone_blurb = 'Recently a few useful documents turned up on the web related to JavaFX, so I thought I&#8217;d briefly provide the links to them in case you weren&#8217;t aware of their existence.Firstly, the JavaFX team updated the JavaFX 1.3 API documentation. There...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
Recently a few useful documents turned up on the web related to JavaFX, so I thought I&#8217;d briefly provide the links to them in case you weren&#8217;t aware of their existence.
Firstly, the JavaFX team updated the JavaFX 1.3 API documentation. There is a bunch of new content for much of the API, and improved package [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
var dzone_url = 'http://fxexperience.com/2010/06/three-useful-javafx-links/';
var dzone_title = 'Three Useful JavaFX Links';
var dzone_blurb = 'Recently a few useful documents turned up on the web related to JavaFX, so I thought I&#8217;d briefly provide the links to them in case you weren&#8217;t aware of their existence.Firstly, the JavaFX team updated the JavaFX 1.3 API documentation. There...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>Recently a few useful documents turned up on the web related to JavaFX, so I thought I&#8217;d briefly provide the links to them in case you weren&#8217;t aware of their existence.</p>
<p>Firstly, the JavaFX team updated the <a href="http://java.sun.com/javafx/1.3/docs/api">JavaFX 1.3 API documentation</a>. There is a bunch of new content for much of the API, and improved package documentation (which you can see by clicking the arrow on the main page relevant to the package you&#8217;re interested in). In particular, the javafx.animation, javafx.scene, javafx.scene.control and javafx.scene.chart packages have a bunch of useful information.</p>
<p>Secondly, with the huge improvements to CSS support in JavaFX 1.3, we&#8217;ve published a <a href="http://java.sun.com/javafx/1.3/docs/api/javafx.scene/doc-files/cssref.html">comprehensive CSS guide</a>. This is a huge resource to people interested in styling JavaFX user interfaces, as it lists all available css properties for each control.</p>
<p>Finally, for those interested in ensuring your coding style is following convention, the best resource is <a href="http://wikis.sun.com/display/JavaFxCodeConv/Home">Tor Norbye&#8217;s JavaFX coding conventions</a> document. It&#8217;s not the definitive style guide for JavaFX, but it is a great starting point. I think there is only one difference between his conventions and what we use internally, and he notes this in the page.</p>
<p>There we go &#8211; a few very useful resources that you may be interested in perusing in a spare moment.</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/lLAdoB9Br24" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2010/06/three-useful-javafx-links/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2010/06/three-useful-javafx-links/</feedburner:origLink></item>
	</channel>
</rss>
