<?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>Tue, 07 Feb 2012 03:26:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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, February 7</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/o9Pa5h1m2aM/</link>
		<comments>http://fxexperience.com/2012/02/javafx-links-of-the-week-february-7/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 03:26:50 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1703</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/2012/02/javafx-links-of-the-week-february-7/';
var dzone_title = 'JavaFX links of the week, February 7';
var dzone_blurb = 'Sorry for the delayed post this week, I&#8217;ve been a little bogged down in other work recently. But anywho, here we go for another week &#8211; enjoy!  JavaFXRichard Bair was busy this week, putting up three blog posts here at FX Experience. The first...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
Sorry for the delayed post this week, I&#8217;ve been a little bogged down in other work recently. But anywho, here we go for another week &#8211; enjoy! JavaFX Richard Bair was busy this week, putting up three blog posts here at FX Experience. The first post talks about his investigation into restricting input on a [...]]]></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/2012/02/javafx-links-of-the-week-february-7/';
var dzone_title = 'JavaFX links of the week, February 7';
var dzone_blurb = 'Sorry for the delayed post this week, I&#8217;ve been a little bogged down in other work recently. But anywho, here we go for another week &#8211; enjoy!  JavaFXRichard Bair was busy this week, putting up three blog posts here at FX Experience. The first...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>Sorry for the delayed post this week, I&#8217;ve been a little bogged down in other work recently. But anywho, here we go for another week &#8211; enjoy! <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h4>JavaFX</h4>
<ul>
<li><strong>Richard Bair</strong> was busy this week, putting up three blog posts here at FX Experience. The first post talks about his investigation into <a href="http://fxexperience.com/2012/02/restricting-input-on-a-textfield/">restricting input on a TextField control</a>. This then leads on to a <a href="http://fxexperience.com/2012/02/moneyfield/">MoneyField control</a> that he has made available, and finally a blog post about how he slightly simplified the MoneyField by <a href="http://fxexperience.com/2012/02/toolbar-in-fxml-no-longer-requires-tag/">adding more DefaultProperty annotations to UI control properties</a>.</li>
<li><strong>Phil Race</strong> has blogged about the <a href="http://blogs.oracle.com/javafx/entry/lcd_text_support_in_javafx">LCD text support in JavaFX 2.1</a>.</li>
<li><strong>Michael Heinrichs</strong> has blogged about <a href="http://blog.netopyr.com/2012/02/02/creating-read-only-properties-in-javafx/">creating read-only properties in JavaFX</a>.</li>
<li><strong>Thom Schindl</strong> announced the <a href="http://tomsondev.bestsolution.at/2012/01/31/efxclipse-0-0-12-released/">release of e(fx)clipse 0.0.12</a>.</li>
<li><strong>Daniel Zwolenski</strong> has published an article on OTN titled &#8220;<a href="http://www.oracle.com/technetwork/articles/java/zonski-1508195.html">Building Java EE Applications in JavaFX 2.0</a>&#8220;.</li>
<li><strong>Adam Bien</strong> has blogged about <a href="http://www.adam-bien.com/roller/abien/entry/setting_javafx_2_runtime_at">setting the JavaFX 2.0 runtime at startup</a> (and solving &#8220;Unable to read ../rt/&#8221; problem).</li>
<li><strong>Jim Weaver</strong> put up a number of quotes from developers with their <a href="http://learnjavafx.typepad.com/weblog/2012/01/i-hear-voices-javafx-21-developer-preview-for-mac-and-linux.html">reactions to the recent release of the developer preview of JavaFX 2.1 for Linux</a>.</li>
<li>For those in the St Louis area, <strong>Weiqi Gao</strong> is giving <a href="http://java.ociweb.com/javasig/">another JavaFX 2.0 talk</a> covering the core concepts.</li>
<li>Speaking of <strong>Weiqi</strong>, he has also blogged about how to get started <a href="http://www.weiqigao.com/blog/2012/02/03/running_32_bit_javafx_2_1_beta_sdk_on_64_bit_ubuntu_11_10.html">running JavaFX 2.1 on a 64-bit Ubuntu</a> install.</li>
<li><strong>Mark Anro Silva</strong> has created a <a href="http://glyphsoft.wordpress.com/2012/02/05/javafx-2-0-neon-globe/">3D neon globe</a> which can be started via webstart (although I can&#8217;t see the source code).</li>
<li><strong>Dustin Marx</strong> has blogged about creating a JavaFX application that <a href="http://marxsoftware.blogspot.co.nz/2012/01/javafx-2-presents-quadratic-formula.html">can solve quadratic equations</a>.</li>
<li><strong>William Antonio</strong> has blogged about a JavaFX application that he has created that <a href="http://fxapps.blogspot.co.nz/2012/01/javafx-app-for-gatein-navigation-rest.html">consumes the GateIn navigation REST API</a>.</li>
<li><strong>Altuğ Uzunali</strong> has created a <a href="http://javafxwidgets.blogspot.co.nz/2012/01/complex-widget-waterfall-display.html">waterfall display</a> (aka a spectrogram).</li>
</ul>
<h4>Swing</h4>
<ul>
<li>SwingX 1.6.3 was <a href="http://www.java.net/forum/topic/javadesktop/java-desktop-technologies/swinglabs/swingx-163-has-been-released?force=449">released this week</a>.</li>
</ul>
<p>That&#8217;s all for another week. Catch you again in a weeks time.</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/o9Pa5h1m2aM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/02/javafx-links-of-the-week-february-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/02/javafx-links-of-the-week-february-7/</feedburner:origLink></item>
		<item>
		<title>ToolBar in FXML No Longer Requires  tag</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/y212Rm9MGzM/</link>
		<comments>http://fxexperience.com/2012/02/toolbar-in-fxml-no-longer-requires-tag/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 20:17:59 +0000</pubDate>
		<dc:creator>Richard Bair</dc:creator>
				<category><![CDATA[FXML]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1696</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/2012/02/toolbar-in-fxml-no-longer-requires-tag/';
var dzone_title = 'ToolBar in FXML No Longer Requires <items> tag';
var dzone_blurb = 'While writing the last blog post on segmented buttons, I found a bug (or rather, a feature missing from ToolBar). I had to use the following FXML:You will notice that the ToolBar required the &lt;items&gt; element for adding the, well, items to the ToolBar....';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
While writing the last blog post on segmented buttons, I found a bug (or rather, a feature missing from ToolBar). I had to use the following FXML: You will notice that the ToolBar required the &#60;items&#62; element for adding the, well, items to the ToolBar. This extra level of verbosity was just asking to be [...]]]></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/2012/02/toolbar-in-fxml-no-longer-requires-tag/';
var dzone_title = 'ToolBar in FXML No Longer Requires <items> tag';
var dzone_blurb = 'While writing the last blog post on segmented buttons, I found a bug (or rather, a feature missing from ToolBar). I had to use the following FXML:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;?import java.lang.*?&gt;&lt;?import javafx.scene.control.*?&gt;&lt;?import...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>While writing the <a href="http://fxexperience.com/2012/02/customized-segmented-toolbar-buttons/">last blog post on segmented buttons</a>, I found a bug (or rather, a feature missing from ToolBar). I had to use the following FXML:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;?import java.lang.*?&gt;
&lt;?import javafx.scene.control.*?&gt;
&lt;?import javafx.scene.layout.*?&gt;

&lt;BorderPane id=&quot;background&quot; prefWidth=&quot;800.0&quot; prefHeight=&quot;600.0&quot; xmlns:fx=&quot;http://javafx.com/fxml&quot;&gt;
    &lt;top&gt;
        &lt;ToolBar&gt;
            &lt;items&gt;
                &lt;Region styleClass=&quot;spacer&quot; /&gt;
                &lt;HBox styleClass=&quot;segmented-button-bar&quot;&gt;
                    &lt;Button text=&quot;Tasks&quot; styleClass=&quot;first&quot; /&gt;
                    &lt;Button text=&quot;Administrator&quot; /&gt;
                    &lt;Button text=&quot;Search&quot; /&gt;
                    &lt;Button text=&quot;Line&quot; /&gt;
                    &lt;Button text=&quot;Process&quot; styleClass=&quot;last&quot; /&gt;
                &lt;/HBox&gt;
            &lt;/items&gt;
        &lt;/ToolBar&gt;
    &lt;/top&gt;
&lt;/BorderPane&gt;
</pre>
<p>You will notice that the ToolBar required the &lt;items&gt; element for adding the, well, items to the ToolBar. This extra level of verbosity was just asking to be smashed. I filed &amp; fixed &amp; Greg reviewed the fix for <a href="http://javafx-jira.kenai.com/browse/RT-19476">RT-19476</a>. As of a few minutes ago, this fix has gone into the control&#8217;s scrum forest and should be making its way into the next weekly build. So now, you can just say:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;?import java.lang.*?&gt;
&lt;?import javafx.scene.control.*?&gt;
&lt;?import javafx.scene.layout.*?&gt;

&lt;BorderPane id=&quot;background&quot; prefWidth=&quot;800.0&quot; prefHeight=&quot;600.0&quot; xmlns:fx=&quot;http://javafx.com/fxml&quot;&gt;
    &lt;top&gt;
        &lt;ToolBar&gt;
            &lt;Region styleClass=&quot;spacer&quot; /&gt;
            &lt;HBox styleClass=&quot;segmented-button-bar&quot;&gt;
                &lt;Button text=&quot;Tasks&quot; styleClass=&quot;first&quot; /&gt;
                &lt;Button text=&quot;Administrator&quot; /&gt;
                &lt;Button text=&quot;Search&quot; /&gt;
                &lt;Button text=&quot;Line&quot; /&gt;
                &lt;Button text=&quot;Process&quot; styleClass=&quot;last&quot; /&gt;
            &lt;/HBox&gt;
        &lt;/ToolBar&gt;
    &lt;/top&gt;
&lt;/BorderPane&gt;
</pre>
<p>It&#8217;s the little things in life, really <img src='http://fxexperience.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/y212Rm9MGzM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/02/toolbar-in-fxml-no-longer-requires-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/02/toolbar-in-fxml-no-longer-requires-tag/</feedburner:origLink></item>
		<item>
		<title>Customized Segmented ToolBar Buttons</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/bj4l77ADZDc/</link>
		<comments>http://fxexperience.com/2012/02/customized-segmented-toolbar-buttons/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 19:17:09 +0000</pubDate>
		<dc:creator>Richard Bair</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[FXML]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[Tips n' Tricks]]></category>
		<category><![CDATA[UI Design]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1681</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/2012/02/customized-segmented-toolbar-buttons/';
var dzone_title = 'Customized Segmented ToolBar Buttons';
var dzone_blurb = 'One of Jasper&#8217;s favorite websites is called Dribbble, which is a place for designers to post whatever work they&#8217;re currently working on for others to view and be inspired from. I got hooked on Dribbble last Thursday and have been looking at...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
One of Jasper&#8217;s favorite websites is called Dribbble, which is a place for designers to post whatever work they&#8217;re currently working on for others to view and be inspired from. I got hooked on Dribbble last Thursday and have been looking at a bunch of the mockups and itching to try implementing some of them [...]]]></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/2012/02/customized-segmented-toolbar-buttons/';
var dzone_title = 'Customized Segmented ToolBar Buttons';
var dzone_blurb = 'One of Jasper&#8217;s favorite websites is called Dribbble, which is a place for designers to post whatever work they&#8217;re currently working on for others to view and be inspired from. I got hooked on Dribbble last Thursday and have been looking at...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>One of Jasper&#8217;s favorite websites is called <a href="http://dribbble.com">Dribbble</a>, which is a place for designers to post whatever work they&#8217;re currently working on for others to view and be inspired from. I got hooked on Dribbble last Thursday and have been looking at a bunch of the mockups and itching to try implementing some of them in JavaFX. Here is my first attempt.</p>
<p><a href="http://dribbble.com/shots/412425-Class-Attendance?list=popular&#038;offset=3"><img src="http://fxexperience.com/wp-content/uploads/2012/02/SegmentedButtonBar-Designer.png" alt="" title="SegmentedButtonBar Designer" width="800" class="aligncenter size-full wp-image-1691" /></a></p>
<p>One of the use cases we used for our CSS support and our ToolBar API was that we wanted to support a style of toolbar button which (at least for me) was popularized on the Mac, which is referred to by Cocoa as a &#8220;segmented&#8221; button. This is essentially nothing more than an HBox of buttons that has been styled such that the first button has rounded left edges, the center buttons are squared up, and the last button has rounded right edges. In the image above by <a href="http://dribbble.com/bady"/>Bady</a>, you can see the segmented button bar in the toolbar area of the application.<br />
<span id="more-1681"></span><br />
So to begin with, here is the Java code that goes into producing this app. This one is going to only have a toolbar, segmented button bar, and then the body area will just be the blue color you see in the above design. I actually will list two different examples here which both produce the same view and which both use the same CSS file. The first is just plain Java, while the second uses FXML to define the UI and a Java file simply loads the UI and configures the stage.</p>
<p><b>SegmentedButtonBarApp &#8211; Just Java</b></p>
<pre class="brush: java; title: ; notranslate">
public class SegmentedButtonBarApp extends Application {
    @Override public void start(Stage stage) throws Exception {
        BorderPane root = new BorderPane();
        root.setId(&quot;background&quot;);

        ToolBar toolBar = new ToolBar();
        root.setTop(toolBar);

        Region spacer = new Region();
        spacer.getStyleClass().setAll(&quot;spacer&quot;);

        HBox buttonBar = new HBox();
        buttonBar.getStyleClass().setAll(&quot;segmented-button-bar&quot;);
        Button sampleButton = new Button(&quot;Tasks&quot;);
        sampleButton.getStyleClass().addAll(&quot;first&quot;);
        Button sampleButton2 = new Button(&quot;Administrator&quot;);
        Button sampleButton3 = new Button(&quot;Search&quot;);
        Button sampleButton4 = new Button(&quot;Line&quot;);
        Button sampleButton5 = new Button(&quot;Process&quot;);
        sampleButton5.getStyleClass().addAll(&quot;last&quot;, &quot;capsule&quot;);
        buttonBar.getChildren().addAll(sampleButton, sampleButton2, sampleButton3, sampleButton4, sampleButton5);
        toolBar.getItems().addAll(spacer, buttonBar);

        Scene scene = new Scene(root, 800, 600);
        scene.getStylesheets().add(getClass().getResource(&quot;segmented.css&quot;).toExternalForm());
        stage.setScene(scene);
        stage.setTitle(&quot;Segmented Button Bar&quot;);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
</pre>
<p><b>SegmentedButtonBarFXMLApp.java and SegmentedButtonBar.fxml &#8211; Java and FXML</b></p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;?import java.lang.*?&gt;
&lt;?import javafx.scene.control.*?&gt;
&lt;?import javafx.scene.layout.*?&gt;

&lt;BorderPane id=&quot;background&quot; prefWidth=&quot;800.0&quot; prefHeight=&quot;600.0&quot; xmlns:fx=&quot;http://javafx.com/fxml&quot;&gt;
    &lt;top&gt;
        &lt;ToolBar&gt;
            &lt;items&gt;
                &lt;Region styleClass=&quot;spacer&quot; /&gt;
                &lt;HBox styleClass=&quot;segmented-button-bar&quot;&gt;
                    &lt;Button text=&quot;Tasks&quot; styleClass=&quot;first&quot; /&gt;
                    &lt;Button text=&quot;Administrator&quot; /&gt;
                    &lt;Button text=&quot;Search&quot; /&gt;
                    &lt;Button text=&quot;Line&quot; /&gt;
                    &lt;Button text=&quot;Process&quot; styleClass=&quot;last&quot; /&gt;
                &lt;/HBox&gt;
            &lt;/items&gt;
        &lt;/ToolBar&gt;
    &lt;/top&gt;
&lt;/BorderPane&gt;
</pre>
<pre class="brush: java; title: ; notranslate">
public class SegmentedButtonBarFXMLApp extends Application{
    @Override public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource(&quot;SegmentedButtonBar.fxml&quot;));
        Scene scene = new Scene(root);
        scene.getStylesheets().add(getClass().getResource(&quot;segmented.css&quot;).toExternalForm());
        stage.setScene(scene);
        stage.setTitle(&quot;Segmented Button Bar From FXML&quot;);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
</pre>
<p>Both of these approach yield the same approach. I think the FXML file in this case is easier to visualize than reading the raw Java code, but either approach is valid. In both approaches you will notice that I have not done any visual styling whatsoever in the code or FXML, it has all been abstracted away to the css file. Here is what the application looks like without any CSS being applied.</p>
<p><a href="http://fxexperience.com/wp-content/uploads/2012/02/Unstyled-SegmentedButtonBar.png"><img src="http://fxexperience.com/wp-content/uploads/2012/02/Unstyled-SegmentedButtonBar.png" alt="" title="Unstyled SegmentedButtonBar" width="754" height="616" class="aligncenter size-full wp-image-1682" /></a></p>
<p>So now lets apply one section of the CSS file at a time, and see how it modifies the look of the application.</p>
<h3>The CSS</h3>
<p>I started off by defining the following rule in CSS:</p>
<pre class="brush: css; title: ; notranslate">
#background {
    -light-black: rgb(74, 75, 78);
    -dark-highlight: rgb(87, 89, 92);
    -dark-black: rgb(39, 40, 40);
    -darkest-black: rgb(5, 5, 5);
    -mid-gray: rgb(216, 222, 227);
    -fx-background-color: -mid-gray;
}
</pre>
<p>There are two things going on in this code. First, you will note that it selects only the node(s) with the id of &#8220;background&#8221;. The node in our scene graph with this id is the BorderPane which forms the root of the scene graph. The first chunk of the CSS file defines the color palette. In JavaFX CSS you can create arbitrary &#8220;variables&#8221; in your CSS by simply defining a declaration, such as <code>-dark-black: rub(39, 40, 40);</code>. Thereafter, you can refer to these named colors.</p>
<div id="attachment_1684" class="wp-caption aligncenter" style="width: 210px"><a href="http://fxexperience.com/wp-content/uploads/2012/02/SegmentedButtonBar-Palette.png"><img src="http://fxexperience.com/wp-content/uploads/2012/02/SegmentedButtonBar-Palette.png" alt="" title="SegmentedButtonBar Palette" width="200" height="40" class="size-full wp-image-1684" /></a><p class="wp-caption-text">SegmentedButtonBar Palette</p></div>
<p>After doing nothing other than defining the color palette and the background, our app now looks like this:</p>
<p><a href="http://fxexperience.com/wp-content/uploads/2012/02/Styled-Background.png"><img src="http://fxexperience.com/wp-content/uploads/2012/02/Styled-Background.png" alt="" title="Styled Background" width="754" height="616" class="aligncenter size-full wp-image-1686" /></a></p>
<p>The background now has this mid-gray color, while the rest of the app looks unchanged. Now, lets style the ToolBar.</p>
<pre class="brush: css; title: ; notranslate">
.tool-bar {
    -fx-base: -dark-black;
    -fx-font-size: 12pt;
    -fx-background-color:
        linear-gradient(to bottom, derive(-fx-base,-30%), derive(-fx-base,-60%)),
        linear-gradient(to bottom, -light-black 2%, -dark-black 98%);
    -fx-background-insets: 0, 0 0 1 0;
    -fx-padding: .9em 0.416667em .9em 0.416667em;
    -fx-effect: dropshadow(two-pass-box,black,5,.2,0,0);
}
</pre>
<p>Here, I am selecting all toolbars in my app to be styled like this. I could have given my tool bar a special style class or ID so that I only targeted it, but in this case this is OK, since I am not using any other tool bars in my app, and if I were, I could style them explicitly by style class or ID if I wanted to. I am telling the toolbar to use the base color of -dark-black. I think the only reason for doing so is so that those automatically derived colors that I&#8217;m not about to override (of which I think only the text fill is ultimately going to be affected) will be styled correctly by default for being on a dark background. I&#8217;ve tweaked the font size to be a bit smaller (on mac it defaults to 13pt).</p>
<p>I&#8217;ve given the toolbar a new background gradient. It simply goes from top-to-bottom. I actually copied this out of caspian.css and then modified the main gradient (the second one in the list) to go from our -light-black palette color to our -dark-black gradient color. I tweaked the insets so that the border (the first gradient in the list) isn&#8217;t drawn on the bottom of the toolbar. I also tweaked the padding so that it would come out pretty close to the designer&#8217;s intent. Finally, I added a drop shadow.</p>
<p><a href="http://fxexperience.com/wp-content/uploads/2012/02/Styled-ToolBar.png"><img src="http://fxexperience.com/wp-content/uploads/2012/02/Styled-ToolBar.png" alt="" title="Styled ToolBar" width="640" height="145" class="aligncenter size-full wp-image-1687" /></a></p>
<p>Now that we&#8217;ve styled the tool bar, it is time to style the segmented buttons (that is, after all, what this post is supposed to be about!). Actually styling the segmented buttons is really pretty easy.</p>
<pre class="brush: css; title: ; notranslate">
.segmented-button-bar .button {
    -fx-background-color:
        -darkest-black,
        -dark-highlight,
        linear-gradient(to bottom, -light-black 2%, -dark-black 98%);
    -fx-background-insets: 0, 1 1 1 0, 2 1 1 1;
    -fx-background-radius: 0;
    -fx-padding: 0.4em 1.833333em 0.4em 1.833333em;
}

.segmented-button-bar .button.first {
    -fx-background-insets: 0, 1, 2 1 1 1;
    -fx-background-radius: 3 0 0 3, 2 0 0 2, 2 0 0 2;
}

.segmented-button-bar .button.last {
    -fx-background-insets: 0, 1 1 1 0, 2 1 1 1;
    -fx-background-radius: 0 3 3 0, 0 2 2 0, 0 2 2 0;
}

.segmented-button-bar .button:pressed {
    -fx-background-color:
        -darkest-black,
        rgb(55, 57, 58),
        linear-gradient(to top, -light-black 2%, -dark-black 98%);
}
</pre>
<p>The segmented buttons are styled such that the first and last are half-rounded, and the middle buttons are squared up. With web CSS you have the &#8220;first-child&#8221; and &#8220;last-child&#8221; pseudo-classes. However these are not implemented in JavaFX, so instead I added the &#8220;first&#8221; and &#8220;last&#8221; style classes to the first and last buttons, respectively. This allows me to use a nice CSS rule to target them separately from any other random button added to the segmented button bar.</p>
<p>Oh, and my &#8220;segmented button bar&#8221; isn&#8217;t a control &#8212; it is just an HBox with some special CSS style. I gave the hbox the style class &#8220;segmented-button-bar&#8221;, and then here from CSS I will target all buttons that are within a segmented-button-bar, and style them specially.</p>
<p>The button is drawn using 3 overlapping background fills. The first is the dark outline, the second is the &#8220;highlight&#8221; &#8212; a lighter line draw to give the bezel look, and then the gradient that fills the rest of the body. The only trick with these is to correctly specify the insets and the corner radius&#8217; so everything ends up looking right. Look closely at the following zoomed-in screenshot of the design:</p>
<p><a href="http://fxexperience.com/wp-content/uploads/2012/02/Search-Button-Zoomed-In.png"><img src="http://fxexperience.com/wp-content/uploads/2012/02/Search-Button-Zoomed-In.png" alt="" title="Search Button Zoomed In" width="810" height="264" class="aligncenter size-full wp-image-1688" /></a></p>
<p>You will notice that there is, on the left of this button, a black line and a highlight line. So does the black line belong to the button to the left of the &#8220;Search&#8221; button? Who draws it? In my case, I decided that the highlight line on the left would be drawn by this button, and the dark line on the right would also be drawn by this button. Thus you can butt multiple buttons against each other and they appear to &#8220;share&#8221; a border. Notice that the middle button draws the black lines on the top and bottom. So basically what I did was draw the black background, then draw a highlight background overtop of it adjusted such that it drew over most of the black background, just leaving 1 px on the top and bottom showing through. Then I drew the main fill adjusted so that the highlight was obscured except for 1 px on the top and left.</p>
<p>The first and last buttons were likewise tweaked to get the right look. The only additional thing done there was to make sure that the corner radius for the top-left and bottom-left edges (for the first button) were rounded and the top-right and bottom-right were squared. The same idea for the last button.</p>
<p>And that&#8217;s it. A SegmentedButtonBar where you can drop in buttons and they will be styled to match the colors, gradients, and so forth that the designer intended. And done by me: somebody who, unlike Jasper, isn&#8217;t very good at making a pretty UI <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Oh, you may be wondering about that &#8220;spacer&#8221; region. I just gave it a simple style to push over the button bar a little ways.</p>
<pre class="brush: css; title: ; notranslate">
.tool-bar .spacer {
    -fx-padding: 0 5.417em 0 0;
}
</pre>
<p>And finally, our app looks pretty good!</p>
<p><a href="http://fxexperience.com/wp-content/uploads/2012/02/SegmentedButtonBar-App-Final2.png"><img src="http://fxexperience.com/wp-content/uploads/2012/02/SegmentedButtonBar-App-Final2.png" alt="" title="SegmentedButtonBar-App-Final2" width="754" height="616" class="aligncenter size-full wp-image-1701" /></a></p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/bj4l77ADZDc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/02/customized-segmented-toolbar-buttons/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/02/customized-segmented-toolbar-buttons/</feedburner:origLink></item>
		<item>
		<title>MoneyField</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/DJ48cd29Jp8/</link>
		<comments>http://fxexperience.com/2012/02/moneyfield/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 22:47:40 +0000</pubDate>
		<dc:creator>Richard Bair</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1675</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/2012/02/moneyfield/';
var dzone_title = 'MoneyField';
var dzone_blurb = 'I started writing an article about how to write new UI controls for OpenJFX using all the internal APIs and architecture and so forth. But then I discovered that the control I was writing as a proof of concept was not using any private API at all, and...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
I started writing an article about how to write new UI controls for OpenJFX using all the internal APIs and architecture and so forth. But then I discovered that the control I was writing as a proof of concept was not using any private API at all, and actually was implementing the Skin differently than [...]]]></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/2012/02/moneyfield/';
var dzone_title = 'MoneyField';
var dzone_blurb = 'I started writing an article about how to write new UI controls for OpenJFX using all the internal APIs and architecture and so forth. But then I discovered that the control I was writing as a proof of concept was not using any private API at all, and...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>I started writing an article about how to write new UI controls for OpenJFX using all the internal APIs and architecture and so forth. But then I discovered that the control I was writing as a proof of concept was not using any private API at all, and actually was implementing the Skin differently than I had imagined previously, and I thought I ought to blog about it. Behold, the MoneyField!</p>
<p><a href="http://fxexperience.com/wp-content/uploads/2012/02/MoneyField-Screenshot.png"><img src="http://fxexperience.com/wp-content/uploads/2012/02/MoneyField-Screenshot.png" alt="" title="MoneyField Screenshot" width="556" height="469" class="aligncenter size-full wp-image-1676" /></a></p>
<p><span id="more-1675"></span></p>
<p>The design space for a MoneyField is quite interesting. I did a bunch of research and tried out various different representations of &#8220;money&#8221; in Java, including <a href="http://joda-money.sourceforge.net/">Joda-Money</a>, but in the end the parsing was not satisfactory and I concluded to just use a good old fashioned BigDecimal to represent a monetary value. The best blog I found talking about the issues with BigDecimal for representing Money is this one titled <a href="http://lemnik.wordpress.com/2011/03/25/bigdecimal-and-your-money/">BigDecimal and Your Money</a>. I think this same technique that I&#8217;m going to show works equally well whatever the data type is.</p>
<p>The most complex part of implementing this control was using the DecimalFormat for parsing the result back. In fact, I had a lot of trouble parsing the text in the MoneyField and producing a reliable BigDecimal out of it. I&#8217;m sure the implementation is lousy compared to what an expert in parsing such things could do, and I would welcome any feedback on my present implementation.</p>
<p>Writing the Control itself was trivial. I extended MoneyField from Control, and added a <code>value</code> property for holding the BigDecimal that would represent the monetary value of this control. I added a few other properties such as <code>editable</code>, <code>promptText</code>, and <code>prefColumnCount</code>. I also added an onAction event to MoneyField.</p>
<p>Now, there are some interesting things to talk about for you aspiring UI controls authors. Lets take a brief walk through the code.</p>
<pre class="brush: java; title: ; notranslate">
public class MoneyField extends Control {
    /**
     * Creates a new MoneyField. The style class is set to &quot;money-field&quot;.
     */
    public MoneyField() {
        getStyleClass().setAll(&quot;money-field&quot;);
    }

    @Override protected String getUserAgentStylesheet() {
        return getClass().getResource(&quot;MoneyField.css&quot;).toExternalForm();
    }
}
</pre>
<p>Every third party UI control must define the essential skeletal structure that you see in the above code snippet. You should provide a no-arg constructor (or it may not work in FXML). In your constructor, you should set the style class of the control to be the &#8220;css-ized&#8221; name of your control. Just toLowerCase and separate words by dashes. Then, because I want my skin to be entirely defined by CSS, I will override the getUserAgentStylesheet method and have it return a reference to a css file that I am going to define which acts as the &#8220;user agent stylesheet&#8221; for this control. That is, it provides the default CSS style for this control. Here is what my CSS file looks like:</p>
<pre class="brush: css; title: ; notranslate">
#money-text-field {
    -fx-skin: &quot;com.sun.javafx.scene.control.skin.TextFieldSkin&quot;;
}

.money-field {
    -fx-skin: &quot;com.fxexperience.javafx.scene.control.skin.MoneyFieldSkin&quot;;
    -fx-background-color: -fx-shadow-highlight-color, -fx-text-box-border, -fx-control-inner-background;
    -fx-background-insets: 0, 1, 2;
    -fx-background-radius: 3, 2, 2;
    -fx-padding: 3 5 3 5;
    -fx-prompt-text-fill: derive(-fx-control-inner-background,-30%);
    -fx-cursor: text;
}

.money-field:focused {
    -fx-background-color: -fx-focus-color, -fx-text-box-border, -fx-control-inner-background;
    -fx-background-insets: -0.4, 1, 2;
    -fx-background-radius: 3.4, 2, 2;
}

.money-field:disabled {
    -fx-opacity: -fx-disabled-opacity;
}
</pre>
<p>There really isn&#8217;t a lot to say here, other than you can see I have a little trickery around the #money-text-field. Basically, I want the developer to be able to style the money field from CSS using .money-field, but I need to make sure the Skin used with the inner TextField is still a normal TextField. You&#8217;ll see how this fits together in a minute when I describe how the MoneyFieldSkin works.</p>
<p>Back in the MoneyField.java file, I also defined the above mentioned properties and events. First, here is what a &#8220;normal&#8221; property looks like. It is fully observable, readable, and writable.</p>
<pre class="brush: java; title: ; notranslate">
    /**
     * The value of the MoneyField. If null, the value will be treated as &quot;0&quot;, but
     * will still actually be null.
     */
    private ObjectProperty&lt;BigDecimal&gt; value = new SimpleObjectProperty&lt;BigDecimal&gt;(this, &quot;value&quot;);
    public final BigDecimal getValue() { return value.get(); }
    public final void setValue(BigDecimal value) { this.value.set(value); }
    public final ObjectProperty&lt;BigDecimal&gt; valueProperty() { return value; }
</pre>
<p>I am using the SimpleObjectProperty, which takes as parameters a reference to the bean that defined it, and the name of the property. The value of the <code>value</code> property defaults to null. Our doclet produces javadoc on the getter and setter without having to actually write it manually, so that&#8217;s why docs are missing for those. The editable property is likewise defined as a SimpleBooleanProperty.</p>
<p>The onAction is a very straightforward implementation. If you write your own controls and want to include your own action events, it is very easy to do:</p>
<pre class="brush: java; title: ; notranslate">
    /**
     * The action handler associated with this MoneyField, or
     * &lt;tt&gt;null&lt;/tt&gt; if no action handler is assigned.
     *
     * The action handler is normally called when the user types the ENTER key.
     */
    private ObjectProperty&lt;EventHandler&lt;ActionEvent&gt;&gt; onAction = new ObjectPropertyBase&lt;EventHandler&lt;ActionEvent&gt;&gt;() {
        @Override protected void invalidated() {
            setEventHandler(ActionEvent.ACTION, get());
        }

        @Override public Object getBean() { return MoneyField.this; }
        @Override public String getName() { return &quot;onAction&quot;; }
    };
    public final ObjectProperty&lt;EventHandler&lt;ActionEvent&gt;&gt; onActionProperty() { return onAction; }
    public final EventHandler&lt;ActionEvent&gt; getOnAction() { return onActionProperty().get(); }
    public final void setOnAction(EventHandler&lt;ActionEvent&gt; value) { onActionProperty().set(value); }
}
</pre>
<p>You&#8217;ll notice that in the invalidated method of the property I call setEventHandler. This method exists for the registration of such event handlers with the system. Another interesting thing here is that I&#8217;m not extending SimpleObjectProperty, but rather I&#8217;m extending ObjectPropertyBase.</p>
<p>Every property must implement the getBean() and getName() method. SimpleXXX properties have fields which hold the bean &#038; name, and you supply them in the constructor. But XXXPropertyBase properties have no such fields, and you must implement these methods. Why chose one over the other? Well, SimpleXXX properties will have smaller static footprint because they are using a class instead of defining a class, but will have larger dynamic footprint because they have two additional fields which must be saved for each instance. XXXPropertyBase uses larger static footprint because it defines a class, but smaller dynamic footprint because it doesn&#8217;t have to save these two fields. Since I had to subclass an object property anyway for the sake of implementing the invalidated method, I might as well extend ObjectPropertyBase and save a couple fields at runtime.</p>
<p>The Skin for MoneyField was quite interesting. At first I thought I would extend from TextFieldSkin (an internal implementation in JavaFX) but then discovered this wasn&#8217;t necessary. Instead, I could just implement the Skin interface and return a TextField as the &#8220;node&#8221; of the Skin. So the MoneyField defines my UI, and the TextField is actually what I end up using to represent the MoneyField. And then there is a pile of glue code which ties the TextField to the MoneyField. The other nice thing about this approach was that I could implement the entirety of MoneyField and MoneyFieldSkin without using any private API (which, when I started writing this, I didn&#8217;t think was possible).</p>
<pre class="brush: java; title: ; notranslate">
public class MoneyFieldSkin implements Skin&lt;MoneyField&gt; {
    /**
     * The {@code Control} that is referencing this Skin. There is a
     * one-to-one relationship between a {@code Skin} and a {@code Control}.
     * When a {@code Skin} is set on a {@code Control}, this variable is
     * automatically updated.
     */
    private MoneyField control;

    /**
     * This textField is used to represent the MoneyField.
     */
    private TextField textField;

    /**
     * Create a new MoneyFieldSkin.
     * @param control The MoneyField
     */
    public MoneyFieldSkin(final MoneyField control) {
        this.control = control;

        // Create the TextField that we are going to use to represent this MoneyFieldSkin.
        // The textField restricts input so that only valid digits that contribute to the
        // Money can be input.
        textField = new TextField() { // ...
        };

        // ... and a lot more stuff!
    }

    @Override public MoneyField getSkinnable() {
        return control;
    }

    @Override public Node getNode() {
        return textField;
    }

    /**
     * Called by a Skinnable when the Skin is replaced on the Skinnable. This method
     * allows a Skin to implement any logic necessary to clean up itself after
     * the Skin is no longer needed. It may be used to release native resources.
     * The methods {@link #getSkinnable()} and {@link #getNode()}
     * should return null following a call to dispose. Calling dispose twice
     * has no effect.
     */
    @Override public void dispose() {
        textField = null;
    }

    // ... and a lot more stuff!
}
</pre>
<p>The above code lays out the very basic skeletal structure of a Skin. This skin implements the Skin interface directly. The constructor takes the MoneyField it will be working with, and creates the TextField which will represent the skin (or &#8220;draw&#8221; the skin). In the dispose method, we throw away the TextField.</p>
<p>If you ran the code above, you would find a MoneyField that looked and felt like a TextField. None of the properties on the MoneyField would work, but from a visual perspective and a text entry perspective you&#8217;d have, essentially, a TextField. The rest of MoneyFieldSkin is devoted to wiring up the MoneyField API to the TextField and implementing all the parsing and formatting necessary to make it look like a money field.</p>
<p>The remainder of the MoneyFieldSkin isn&#8217;t worth going through in this blog post, though you can <a href='http://fxexperience.com/wp-content/uploads/2012/02/MoneyField.zip'>download the Intellij project</a> and check it out for yourself.</p>
<p>When Jonathan tried this out last night he was getting exceptions with the New Zealand currency. I suspect there may be problems in Australia too. I&#8217;m hoping one of our readers from down under will give it a look and see where my bug is <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>Using the MoneyField is really very straightforward. I hope it is actually useful to boot. I&#8217;m wondering if anybody industrious out there might take this design strategy and write an EmailField and UrlField control, maybe a NumberField control too! It seems eminently doable using only the public API and would make a great addition to the ecosystem (as well as a great addition to the toolkit!).</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/DJ48cd29Jp8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/02/moneyfield/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/02/moneyfield/</feedburner:origLink></item>
		<item>
		<title>Restricting Input on a TextField</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/JLNwd8agswQ/</link>
		<comments>http://fxexperience.com/2012/02/restricting-input-on-a-textfield/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 16:56:48 +0000</pubDate>
		<dc:creator>Richard Bair</dc:creator>
				<category><![CDATA[Tips n' Tricks]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1672</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/2012/02/restricting-input-on-a-textfield/';
var dzone_title = 'Restricting Input on a TextField';
var dzone_blurb = 'I had some little sample I wanted to write where I had a TextField that restricted input. Maybe somebody else out there has already figured out how to do this elegantly, but I hadn&#8217;t and thought it would be worth a small post to demonstrate the...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
I had some little sample I wanted to write where I had a TextField that restricted input. Maybe somebody else out there has already figured out how to do this elegantly, but I hadn&#8217;t and thought it would be worth a small post to demonstrate the technique. Within the TextInputControl is a Content, which actually [...]]]></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/2012/02/restricting-input-on-a-textfield/';
var dzone_title = 'Restricting Input on a TextField';
var dzone_blurb = 'I had some little sample I wanted to write where I had a TextField that restricted input. Maybe somebody else out there has already figured out how to do this elegantly, but I hadn&#8217;t and thought it would be worth a small post to demonstrate the...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>I had some little sample I wanted to write where I had a TextField that restricted input. Maybe somebody else out there has already figured out how to do this elegantly, but I hadn&#8217;t and thought it would be worth a small post to demonstrate the technique.</p>
<p>Within the TextInputControl is a Content, which actually models the TextInputControl&#8217;s content. So for example, this is where we strip out newlines and such if you paste a String into a TextField that contains such characters, but in TextArea we allow those sorts of modifications. There is a protected getContent() method, so in theory a subclass of TextInputControl can manipulate the content directly, although in the case of TextField, it does not.</p>
<p>In fact, the only places in all the code that actually modify the TextField&#8217;s text is in the replaceText and replaceSelection methods defined on TextInputControl. So all you have to do is subclass TextField and override these two methods.</p>
<pre class="brush: java; title: ; notranslate">
field = new TextField() {
    @Override public void replaceText(int start, int end, String text) {
        // If the replaced text would end up being invalid, then simply
        // ignore this call!
        if (!text.matches(&quot;[a-z]&quot;)) {
            super.replaceText(start, end, text);
        }
    }

    @Override public void replaceSelection(String text) {
        if (!text.matches(&quot;[a-z]&quot;)) {
            super.replaceSelection(text);
        }
    }
};
</pre>
<p>In the future we may want to add a more specific method (maybe called &#8220;accept&#8221; which takes the proposed new string after the modification) so that in the off chance that TextField or TextInputControl ends up modifying the content from some additional methods beyond these two, you could still have a reliable way to reject invalid input. However for the time being, this should work just fine!</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/JLNwd8agswQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/02/restricting-input-on-a-textfield/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/02/restricting-input-on-a-textfield/</feedburner:origLink></item>
		<item>
		<title>LCD Text support in JavaFX 2.1 Developer Preview</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/8vRih7IZl2s/</link>
		<comments>http://fxexperience.com/2012/01/lcd-text-support-in-javafx-2-1-developer-preview/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 02:43:16 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tips n' Tricks]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1644</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/2012/01/lcd-text-support-in-javafx-2-1-developer-preview/';
var dzone_title = 'LCD Text support in JavaFX 2.1 Developer Preview';
var dzone_blurb = 'Phil Race has posted a blog post over at the JavaFX Blog on the addition of LCD text support in the latest JavaFX 2.1 developer preview.LCD sub-pixel text has become a must-have for many Windows desktop users, who have become accustomed to its superior...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
Phil Race has posted a blog post over at the JavaFX Blog on the addition of LCD text support in the latest JavaFX 2.1 developer preview. LCD sub-pixel text has become a must-have for many Windows desktop users, who have become accustomed to its superior legibility and less blocky appearance at smaller point sizes over hinted black [...]]]></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/2012/01/lcd-text-support-in-javafx-2-1-developer-preview/';
var dzone_title = 'LCD Text support in JavaFX 2.1 Developer Preview';
var dzone_blurb = 'Phil Race has posted a blog post over at the JavaFX Blog on the addition of LCD text support in the latest JavaFX 2.1 developer preview.LCD sub-pixel text has become a must-have for many Windows desktop users, who have become accustomed to its superior...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p><a href="http://fxexperience.com/wp-content/uploads/2012/01/ensemble-lcd1.png"><img class="aligncenter size-full wp-image-1647" title="ensemble-lcd" src="http://fxexperience.com/wp-content/uploads/2012/01/ensemble-lcd1.png" alt="" width="804" height="322" /></a></p>
<p><strong>Phil Race</strong> has posted a blog post over at the JavaFX Blog on the addition of <a href="http://blogs.oracle.com/javafx/entry/lcd_text_support_in_javafx">LCD text support in the latest JavaFX 2.1 developer preview</a>.</p>
<div>
<p style="padding-left: 30px;">LCD sub-pixel text has become a must-have for many Windows desktop users, who have become accustomed to its superior legibility and less blocky appearance at smaller point sizes over hinted black and white text, and being sharper than grey scale anti-aliased text at the same size.</p>
<p style="padding-left: 30px;">Java SE has supported LCD subpixel text on AWT heavyweights and also on Swing components using Java 2D for many years. However up until now, JavaFX has supported only more Mac OS X-like grey scale smoothed text.</p>
<p style="padding-left: 30px;">For the JavaFX 2.1 release we&#8217;ve added the ability to use Windows-style LCD sub-pixel rendering. All the JavaFX UI controls will be LCD-text enabled by default on Windows, as will &#8220;WebView&#8221;, the Webkit-based node for rendering Web content.</p>
<p style="padding-left: 30px;">Applications can also opt-in to use LCD text on the low-level scenegraph &#8220;Text&#8221; node by a new API : Text.setFontSmoothingType(FontSmoothingType.LCD));</p>
</div>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/8vRih7IZl2s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/01/lcd-text-support-in-javafx-2-1-developer-preview/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/01/lcd-text-support-in-javafx-2-1-developer-preview/</feedburner:origLink></item>
		<item>
		<title>JavaFX links of the week, January 30</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/oHd9AkQv_DE/</link>
		<comments>http://fxexperience.com/2012/01/javafx-links-of-the-week-january-30/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 03:02:29 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1641</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/2012/01/javafx-links-of-the-week-january-30/';
var dzone_title = 'JavaFX links of the week, January 30';
var dzone_blurb = 'These intros become harder as the weeks go by. The core message is always the same: Enoy!  JavaFXIt&#8217;s another week, so another developer preview release of JavaFX 2.1 is out for Linux, Mac OS and Windows. This week we are up to build 10.With the...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
These intros become harder as the weeks go by. The core message is always the same: Enoy! JavaFX It&#8217;s another week, so another developer preview release of JavaFX 2.1 is out for Linux, Mac OS and Windows. This week we are up to build 10. With the availability of JavaFX 2.1 developer preview builds for [...]]]></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/2012/01/javafx-links-of-the-week-january-30/';
var dzone_title = 'JavaFX links of the week, January 30';
var dzone_blurb = 'These intros become harder as the weeks go by. The core message is always the same: Enoy!  JavaFXIt&#8217;s another week, so another developer preview release of JavaFX 2.1 is out for Linux, Mac OS and Windows. This week we are up to build 10.With the...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>These intros become harder as the weeks go by. The core message is always the same: Enoy! <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h4>JavaFX</h4>
<ul>
<li>It&#8217;s another week, so another <a href="http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html">developer preview release of JavaFX 2.1 is out</a> for Linux, Mac OS and Windows. This week we are up to build 10.</li>
<li>With the availability of JavaFX 2.1 developer preview builds for Linux, a number of people and news websites covered this. For example: <a href="http://www.weiqigao.com/blog/2012/01/26/javafx_2_1_sdk_developer_preview_comes_to_linux.html">Weigi Gao</a>, <a href="http://jaxenter.com/javafx-2-gets-linux-support-40466.html">Jaxenter</a>, and <a href="http://www.h-online.com/open/news/item/JavaFX-makes-it-across-platform-to-Linux-1420944.html">H online</a>.</li>
<li><strong>Jasper Potts</strong> has put up two blogs posts here at FX Experience. The first post discusses his work on <a href="http://fxexperience.com/2012/01/extending-pathbuilder/">extending the PathBuilder</a> class to include more convenience methods, and secondly he has a post about <a href="http://fxexperience.com/2012/01/curve-fitting-and-styling-areachart/">extending the charts code shipped with JavaFX to apply curve fitting</a>.</li>
<li>Speaking of the builder classes shipped with JavaFX, <strong>Michael Heinrichs</strong>, a member of the JavaFX team, has put up a post about <a href="http://blog.netopyr.com/2012/01/24/advantages-of-javafx-builders/">the advantages of the JavaFX builder APIs</a>.</li>
<li><strong>Kevin Farnham</strong> put up a blog post over at Java.net about <a href="http://weblogs.java.net/blog/editor/archive/2012/01/24/getting-started-very-preliminarily-javafx-21-developer-preview-linux">getting started with the JavaFX 2.1 developer preview on Linux</a>.</li>
<li><strong>Dustin Marx</strong> talks about the <a href="http://marxsoftware.blogspot.com/2012/01/javafx-21-javafx-2s-defaultproperty.html">@DefaultProperty annotation</a> used in the JavaFX APIs, and what this means for you when building user interfaces with FXML.</li>
<li>The GroovyFX library now has <a href="http://groovyfx-project.github.com/">a new website</a>.</li>
<li><strong>Thierry Janaudy</strong> has a blog post showing <a href="http://oogifu.blogspot.com/2012/01/memory-pie-chart-in-tableview-with.html">how to put a pie chart inside a TableView</a> using a custom cell factory, whilst programming in Scala.</li>
<li><strong>Sébastien Bordes</strong> has a post detailing how to <a href="http://blog.webeo.fr/post/2012/01/29/How-to-build-and-package-JavaFX-2-Application-with-Maven">build and package JavaFX application with Maven</a>.</li>
<li><strong>Narayan</strong> has blogged about <a href="http://blog.ngopal.com.np/2012/01/26/fxml-stuffs-include-and-define/">the &#8216;include&#8217; and &#8216;define&#8217; tags in FXML</a>.</li>
<li>Yet another <a href="http://javafxwidgets.blogspot.com/2012/01/simple-calendar-for-javafx-20.html">DatePicker control has appeared</a>, pushing my count to at least five such controls. This week it belongs to <strong>Altuğ Uzunali</strong>.</li>
<li><strong>Andrew Krizhanovsky</strong> let me know about his <a href="http://wikokit.blogspot.com/">wikokit project</a>, which he describes as a &#8220;Machine-readable Wiktionary with GUI now ported to JavaFX 2.0. This version contains huge drop-down list of available languages.&#8221;</li>
</ul>
<p>These conclusions are equally difficult. The core message is always the same: I hope you enjoy what I just linked to, and I hope it was good enough to see you again in a weeks time (where hopefully my introductions and conclusions are slightly more considered!) <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/oHd9AkQv_DE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/01/javafx-links-of-the-week-january-30/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/01/javafx-links-of-the-week-january-30/</feedburner:origLink></item>
		<item>
		<title>Curve fitting and styling AreaChart</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/72-GztX-_xU/</link>
		<comments>http://fxexperience.com/2012/01/curve-fitting-and-styling-areachart/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 05:50:04 +0000</pubDate>
		<dc:creator>Jasper Potts</dc:creator>
				<category><![CDATA[Charts]]></category>
		<category><![CDATA[Tips n' Tricks]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1623</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/2012/01/curve-fitting-and-styling-areachart/';
var dzone_title = 'Curve fitting and styling AreaChart';
var dzone_blurb = 'I was experimenting today with extending AreaChart to do curve fitting for some example code I was hacking on. It is also a example of what can be done with styling JavaFX charts with CSS. Here is the result:// Curve FittingI have to admit I did not work...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
I was experimenting today with extending AreaChart to do curve fitting for some example code I was hacking on. It is also a example of what can be done with styling JavaFX charts with CSS. Here is the result: Curve Fitting I have to admit I did not work out all the Math myself for [...]]]></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/2012/01/curve-fitting-and-styling-areachart/';
var dzone_title = 'Curve fitting and styling AreaChart';
var dzone_blurb = 'I was experimenting today with extending AreaChart to do curve fitting for some example code I was hacking on. It is also a example of what can be done with styling JavaFX charts with CSS. Here is the result:// Curve FittingI have to admit I did not work...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>I was experimenting today with extending AreaChart to do curve fitting for some example code I was hacking on. It is also a example of what can be done with styling JavaFX charts with CSS. Here is the result:</p>
<div id="applet-container" style="background-image: url('/applications/CurveFittedChartApplet/screenshot.png'); width: 540px; height: 440px;"></div>
<p><span id="more-1623"></span><br />
<script type="text/javascript" src="/applications/CurveFittedChartApplet/web-files/dtjava.js"></script><br />
<script type="text/javascript">// <![CDATA[
        dtjava.embed(
            {
             	url : '/applications/CurveFittedChartApplet/CurveFittedChartApplet.jnlp',
                placeholder : 'applet-container',
                width : 540,
                height : 440 
            },
            {
             	javafx : '2.0+'
            },
            {}
	);
// ]]&gt;</script></p>
<h3>Curve Fitting</h3>
<p>I have to admit I did not work out all the Math myself for the curve fitting I found a great article on CodeProject <a href="http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit">&#8220;Draw a Smooth Curve through a Set of 2D Points with Bezier Primitives&#8221;</a>. Then ported the code to Java from C# and wired it up to our AreaChart. My version is not the most efficient as we do not yet have the correct API hooks to make it easy but we are thinking about how to add them. The current implementation extends AreaChart and overrides the layoutPlotChildren() method. That method creates all the nodes need for the chart and populates the node properties of the Series and Data items. So I can call super to let the standard code do its job then look at the Path elements for the stroked Path and filled Path that make up the AreaChart. I can then replace the LineTo elements with CubicCurveTo with the new control points calculated with the maths from the article. This way everything like auto ranging and animation still works as expected. The only waste is we are creating all the LineTo object and then throwing them away to replace them with CubicCurveTo objects. So here is the code that does this:</p>
<pre class="brush: java; title: ; notranslate">
    /** @inheritDoc */
    @Override protected void layoutPlotChildren() {
        super.layoutPlotChildren();
        for (int seriesIndex=0; seriesIndex &lt; getDataSize(); seriesIndex++) {
            final XYChart.Series&lt;Number, Number&gt; series = getData().get(seriesIndex);
            final Path seriesLine = (Path)((Group)series.getNode()).getChildren().get(1);
            final Path fillPath = (Path)((Group)series.getNode()).getChildren().get(0);
            smooth(seriesLine.getElements(), fillPath.getElements());
        }
    }

    private int getDataSize() {
        final ObservableList&lt;XYChart.Series&lt;Number, Number&gt;&gt; data = getData();
        return (data!=null) ? data.size() : 0;
    }

    private static void smooth(ObservableList&lt;PathElement&gt; strokeElements, ObservableList&lt;PathElement&gt; fillElements) {
        // as we do not have direct access to the data, first recreate the list of all the data points we have
        final Point2D[] dataPoints = new Point2D[strokeElements.size()];
        for (int i = 0; i &lt; strokeElements.size(); i++) {
            final PathElement element = strokeElements.get(i);
            if (element instanceof MoveTo) {
                final MoveTo move = (MoveTo)element;
                dataPoints[i] = new Point2D(move.getX(), move.getY());
            } else if (element instanceof LineTo) {
                final LineTo line = (LineTo)element;
                final double x = line.getX(), y = line.getY();
                dataPoints[i] = new Point2D(x, y);
            }
        }
        // next we need to know the zero Y value
        final double zeroY = ((MoveTo) fillElements.get(0)).getY();

        // now clear and rebuild elements
        strokeElements.clear();
        fillElements.clear();
        Pair&lt;Point2D[], Point2D[]&gt; result = calcCurveControlPoints(dataPoints);
        Point2D[] firstControlPoints = result.getKey();
        Point2D[] secondControlPoints = result.getValue();
        // start both paths
        strokeElements.add(new MoveTo(dataPoints[0].getX(),dataPoints[0].getY()));
        fillElements.add(new MoveTo(dataPoints[0].getX(),zeroY));
        fillElements.add(new LineTo(dataPoints[0].getX(),dataPoints[0].getY()));
        // add curves
        for (int i = 1; i &lt; dataPoints.length; i++) {
            final int ci = i-1;
            strokeElements.add(new CubicCurveTo(
                    firstControlPoints[ci].getX(),firstControlPoints[ci].getY(),
                    secondControlPoints[ci].getX(),secondControlPoints[ci].getY(),
                    dataPoints[i].getX(),dataPoints[i].getY()));
            fillElements.add(new CubicCurveTo(
                    firstControlPoints[ci].getX(),firstControlPoints[ci].getY(),
                    secondControlPoints[ci].getX(),secondControlPoints[ci].getY(),
                    dataPoints[i].getX(),dataPoints[i].getY()));
        }
        // end the paths
        fillElements.add(new LineTo(dataPoints[dataPoints.length-1].getX(),zeroY));
        fillElements.add(new ClosePath());
    }
</pre>
<h3>CSS Styling</h3>
<p>This is just the standard AreaChart in terms of the nodes its drawing with. The first part of the CSS is styling the main chart node and its background. We are using a dark gray texture as the background, adding a 1px black border and a drop shadow. Also adjusting the padding a little.</p>
<pre class="brush: css; title: ; notranslate">
.chart {
    -fx-background-image: url(&quot;background.png&quot;);
    -fx-padding: 15 25 15 15;
    -fx-border-color: black;
    -fx-effect: dropshadow( gaussian , rgba(0,0,0,0.8) , 10, 0.0 , 0 , 2 );
}
</pre>
<p>Next we are looking at the background of the plot area, this is the rectangular area bordered by the two axis. We are using two background images here one a colored glow and the second is transparent white gridlines. The first image is sized to &#8220;cover&#8221; the whole area of the plot background and the second is tiled to fill. We also add black borders to the top and right to complete a box around the plot area including the two axis lines.</p>
<pre class="brush: css; title: ; notranslate">
.chart-plot-background {
    -fx-background-image: url(&quot;chart-background.png&quot;), url(&quot;graph-gridlines.png&quot;);
    -fx-background-size: cover, auto;
    -fx-background-repeat: no-repeat, repeat;
    -fx-background-position: 0% 0%, 0% 100%;
    -fx-border-color: black black transparent transparent;
}
</pre>
<p>The line that connects the data points we are styling to be 2px wide and white.</p>
<pre class="brush: css; title: ; notranslate">
.chart-series-area-line {
    -fx-stroke: white;
    -fx-stroke-width: 2px;
}
</pre>
<p>The filled area under the line we are styling with a linear gradient from white on the left to 100% transparent white on the right. We also use a blend mode to get the desired effect when blending with the colored background of the plot area.</p>
<pre class="brush: css; title: ; notranslate">
.chart-series-area-fill {
    -fx-fill: linear-gradient(to right, white, rgba(255,255,255,0));
    -fx-blend-mode: OVERLAY;
}
</pre>
<p>Making the plot symbols for each data point white.</p>
<pre class="brush: css; title: ; notranslate">
.chart-area-symbol {
    -fx-background-color: white;
}
</pre>
<p>Hiding the tick marks and changing the color of the axis lines to black</p>
<pre class="brush: css; title: ; notranslate">
.axis {
    -fx-tick-mark-visible: false;
    -fx-minor-tick-visible: false;
    -fx-tick-length: 3;
    -fx-minor-tick-length: 0;
    -fx-border-color: transparent;
}
.axis:bottom {
    -fx-border-color: black transparent transparent transparent;
}
.axis:left {
    -fx-border-color: transparent black transparent transparent;
}
</pre>
<p>Styling the text labels on the axis so they are white with black shadow and a little larger than default.</p>
<pre class="brush: css; title: ; notranslate">
.axis Text{
    -fx-fill: white;
}
.tick-mark {
    -fx-font-size: 10px;
    -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.8) , 0, 0.0 , 0 , 1 );
}
</pre>
<p>There you go that is all you need to take one of our standard charts and make it look completely different. Hopefully this will inspire some of you to try some exciting designs with JavaFX charts.</p>
<h3>Source Code</h3>
<p>The full Netbeans project and code including the maths is available here (<a href="http://fxexperience.com/applications/CurveFittedChartApplet/CurveFittedChart.zip">CurveFittedChart.zip</a>).</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/72-GztX-_xU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/01/curve-fitting-and-styling-areachart/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/01/curve-fitting-and-styling-areachart/</feedburner:origLink></item>
		<item>
		<title>Extending PathBuilder</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/IpeXv2plyfM/</link>
		<comments>http://fxexperience.com/2012/01/extending-pathbuilder/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 21:51:56 +0000</pubDate>
		<dc:creator>Jasper Potts</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tips n' Tricks]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1613</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/2012/01/extending-pathbuilder/';
var dzone_title = 'Extending PathBuilder';
var dzone_blurb = 'I came across the interesting blog &#8220;JavaFx and HTML5 differences&#8221; by Chika Okereke. Looking at the example code and comparing to the HTML Canvas version I thought the Java code could be made less verbose and easier to read.Original CodeSo...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
I came across the interesting blog &#8220;JavaFx and HTML5 differences&#8221; by Chika Okereke. Looking at the example code and comparing to the HTML Canvas version I thought the Java code could be made less verbose and easier to read. Original Code So I hacked together a Extended version of the PathBuilder that ships with JavaFX [...]]]></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/2012/01/extending-pathbuilder/';
var dzone_title = 'Extending PathBuilder';
var dzone_blurb = 'I came across the interesting blog &#8220;JavaFx and HTML5 differences&#8221; by Chika Okereke. Looking at the example code and comparing to the HTML Canvas version I thought the Java code could be made less verbose and easier to read.Original CodePath...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>I came across the interesting blog <a href="http://www.jpedal.org/PDFblog/2012/01/javafx-and-html5-differences-shapes-work-differently/" target="_blank">&#8220;JavaFx and HTML5 differences&#8221;</a> by Chika Okereke. Looking at the example code and comparing to the HTML Canvas version I thought the Java code could be made less verbose and easier to read.</p>
<p><b>Original Code</b>
<pre class="brush: java; title: ; notranslate">Path path_4 = new Path();
ObservableList shape_4 = path_4.getElements();
shape_4.add(new MoveTo(50,50));
shape_4.add(new LineTo(150,50));
shape_4.add(new LineTo(150,150));
shape_4.add(new LineTo(50,150));
shape_4.add(new LineTo(50,50));
path_4.setStrokeWidth(2);
path_4.setStroke(Color.rgb(255,0,0));</pre>
<p>So I hacked together a Extended version of the PathBuilder that ships with JavaFX 2.0 adding methods for all of the path elements like moveTo() etc. The end result seems much cleaner code to me, what do you think?</p>
<p><b>Code with new Builder</b>
<pre class="brush: java; title: ; notranslate">Path path4 = PathBuilderExtended.create()
        .moveTo(50, 50)
        .lineTo(150, 50)
        .lineTo(150, 150)
        .lineTo(50, 150)
        .closePath()
        .strokeWidth(2)
        .stroke(Color.RED)
        .build();
</pre>
<p>This seemed a lot cleaner and simpler to read. I have filed a feature request <a href="http://javafx-jira.kenai.com/browse/RT-19266">RT-19266</a> in JIRA to add this to the platform. Feel free to comment on the bug if you any feedback or better suggestions. Also I have attached a implementation of this builder to the bug so you can see how it would be implemented or use it with your code today. </p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/IpeXv2plyfM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/01/extending-pathbuilder/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/01/extending-pathbuilder/</feedburner:origLink></item>
		<item>
		<title>JavaFX links of the week, January 24</title>
		<link>http://feedproxy.google.com/~r/fxexperience/~3/6dKb9jWRMlM/</link>
		<comments>http://fxexperience.com/2012/01/javafx-links-of-the-week-january-24/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 00:25:04 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1610</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/2012/01/javafx-links-of-the-week-january-24/';
var dzone_title = 'JavaFX links of the week, January 24';
var dzone_blurb = 'A heap of links this week (partly because I&#8217;m a day and a half late with this post!). Hopefully something for everyone  JavaFX 2.1 developer preview build 09 has been released. For the first time, this release includes support for Windows, Mac OS,...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
A heap of links this week (partly because I&#8217;m a day and a half late with this post!). Hopefully something for everyone JavaFX 2.1 developer preview build 09 has been released. For the first time, this release includes support for Windows, Mac OS, and Linux. You can read a bit more about this here. Amy [...]]]></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/2012/01/javafx-links-of-the-week-january-24/';
var dzone_title = 'JavaFX links of the week, January 24';
var dzone_blurb = 'A heap of links this week (partly because I&#8217;m a day and a half late with this post!). Hopefully something for everyone  JavaFX 2.1 developer preview build 09 has been released. For the first time, this release includes support for Windows, Mac OS,...';
var dzone_style = '1';
//-->
</script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script> 
</div>
<p>A heap of links this week (partly because I&#8217;m a day and a half late with this post!). Hopefully something for everyone <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<ul>
<li>JavaFX 2.1 developer preview build 09 <a href="http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html">has been released</a>. For the first time, this release includes support for Windows, Mac OS, <strong>and Linux</strong>. You can <a href="http://blogs.oracle.com/javafx/entry/javafx_2_0_is_cross">read a bit more about this here</a>.<br />
<strong></strong></li>
<li><strong>Amy Fowler&#8217;s</strong> &#8220;<a href="http://www.parleys.com/#st=5&amp;id=2734&amp;sl=0">Interface Layout with JavaFX 2.0</a>&#8221; JavaOne talk is now available on Parleys.</li>
<li><strong>Tom Schindl</strong> has created a <a href="http://tomsondev.bestsolution.at/2012/01/16/svg-for-fxml-conversion/">SVG to FXML converter</a>, which he plans to include in a future release of his e(fx)clipse project.</li>
<li>Yet another JavaFX calendar control has been developed, this time by <strong>Christian Schudt</strong>. The control <a href="http://myjavafx.blogspot.com/2012/01/javafx-calendar-control.html">looks very nice</a> and should be very useful to people needing this kind of functionality in their applications.</li>
<li><strong>Chika Okereke</strong> has put up three blogs posts about the JavaFX PDF support. The <a href="http://www.jpedal.org/PDFblog/2012/01/pdf-to-javafx-conversion-how-to-use-netbeans-plugin-part-1/">first</a> <a href="http://www.jpedal.org/PDFblog/2012/01/pdf-to-javafx-conversion-how-to-use-netbeans-plugin-part-2/">two</a> posts are about the NetBeans support, and then news about the latest release <a href="http://www.jpedal.org/PDFblog/2012/01/4-improvements-to-pdf-to-javafx-conversion-in-latest-release/">containing a few improvements</a>.</li>
<li><strong>Dustin Marx</strong> has two blog posts this week. Firstly, he <a href="http://marxsoftware.blogspot.com/2012/01/focus-on-javafx-2-fxml-with-netbeans-71.html">demonstrates FXML</a> by porting one of his previous applications to use it, and secondly <a href="http://marxsoftware.blogspot.com/2012/01/book-review-javafx-20-introduction-by.html">he reviews</a> the &#8220;JavaFX 2.0: Introduction by Example&#8221; 2.0 book by <strong>Carl Dea</strong>.</li>
<li><strong>Thierry Janaudy</strong> has put up a blog post showing <a href="http://oogifu.blogspot.com/2012/01/scala-javafx-tablecolumns.html">how to use the JavaFX TableView control in a GUI using Scala</a>.</li>
<li><strong>Toni Epple</strong> has reviewed the <a href="http://netbeans.dzone.com/articles/netbeans-71-review-javafx">JavaFX support in the latest 7.1 release of NetBeans</a>.</li>
<li><strong>Sai Predeep Dandem</strong> has blogged about <a href="http://saidandem.blogspot.com/2012/01/sliding-in-javafx-its-all-about.html">creating sliding effects</a> (like those seen in the TitledPane control).</li>
<li><strong>Jim Weaver</strong> has put out a <a href="http://www.dzone.com/links/r/zenpongfx_example_from_the_pro_javafx_2_platform.html">sample app</a> that will be getting discussed in the upcoming Pro JavaFX 2.0 book.</li>
<li><strong>William Antônio Siqueira</strong> has blogged about the DataFX project, demonstrating <a href="http://fxapps.blogspot.com/2012/01/show-data-in-javafx-is-made-easy-by.html">how easy it is to get data into a JavaFX TableView control</a>.</li>
</ul>
<p>Catch you all in a weeks time.</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/fxexperience/~4/6dKb9jWRMlM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/01/javafx-links-of-the-week-january-24/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://fxexperience.com/2012/01/javafx-links-of-the-week-january-24/</feedburner:origLink></item>
	</channel>
</rss>

