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

<channel>
	<title>JavaFX News, Demos and Insight // FX Experience &#187; Tips n&#8217; Tricks</title>
	<atom:link href="http://fxexperience.com/category/tips-n-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://fxexperience.com</link>
	<description>Sharing the Experience of JavaFX</description>
	<lastBuildDate>Mon, 21 May 2012 03:34:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>ListView, custom cell factories, and context menus</title>
		<link>http://fxexperience.com/2012/05/listview-custom-cell-factories-and-context-menus/</link>
		<comments>http://fxexperience.com/2012/05/listview-custom-cell-factories-and-context-menus/#comments</comments>
		<pubDate>Mon, 21 May 2012 03:20:50 +0000</pubDate>
		<dc:creator>Jonathan Giles</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[Tips n' Tricks]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1974</guid>
		<description><![CDATA[One question I see occasionally is people asking how to go about using prebuilt cell factories (such as those provided in the DataFX project run by Johan Vos and I, those sitting in the OpenJFX 2.2 repo in the javafx.scene.control.cell package, or just those that they have created internally), and also show a context menu [...]]]></description>
			<content:encoded><![CDATA[<p>One question I see occasionally is people asking how to go about using prebuilt cell factories (such as those provided in the <a href="http://www.javafxdata.org">DataFX project</a> run by <strong>Johan Vos</strong> and I, those sitting in the <a href="http://openjdk.java.net/projects/openjfx/">OpenJFX</a> 2.2 repo in the javafx.scene.control.cell package, or just those that they have created internally), and also show a context menu when the user right clicks. More generally, the problem is that cell factories are blackboxes, and there is no support for chaining cell factories together (or even getting hold of the cells as they are being used).</p>
<p>The answer is quite simple: wrap the cell factory inside another cell factory, and set the ContextMenu on the wrapping cell. In other words, you would write code such as this (for ListView):</p>
<pre class="brush: java; title: ; notranslate">
// The cell factory you actually want to use to render the cell
Callback&lt;ListView&lt;T&gt;, ListCell&lt;T&gt; wrappedCellFactory = ...; 

// The wrapping cell factory that will set the context menu onto the wrapped cell
Callback&lt;ListView&lt;T&gt;, ListCell&lt;T&gt; cellFactory = new Callback&lt;ListView&lt;T&gt;, ListCell&lt;T&gt;&gt;() {
    @Override public ListCell&lt;T&gt; call(ListView&lt;T&gt; listView) {
        ListCell&lt;T&gt; cell = cellFactory == null ? new DefaultListCell&lt;T&gt;() : wrappedCellFactory.call(listView);
        cell.setContextMenu(contextMenu);
        return cell;
    }
};

// Creating a ListView and setting the cell factory on it
ListView&lt;T&gt; listView = new ListView&lt;T&gt;();
listView.setCellFactory(cellFactory);
</pre>
<p><span id="more-1974"></span></p>
<p>Before I get any further, I should note quickly that this blog post is about ListView / ListCell, but the exact same approach (and even code &#8211; barring a little bit of renaming) is still totally applicable to TreeView and TableView. </p>
<p>One thing to note in the code above is the use of DefaultListCell, which is defined below. I made a new class as I was working on this problem, but I just copy/pasted the code out of ListViewSkin for creating default ListCell instances when the end-developer has not installed a custom cell factory. DefaultListCell therefore just handles the most common case of showing text and/or a &#8216;graphic&#8217; (which can be an arbitrarily complex scenegraph node):</p>
<pre class="brush: java; title: ; notranslate">
import javafx.scene.Node;
import javafx.scene.control.ListCell;

public class DefaultListCell&lt;T&gt; extends ListCell&lt;T&gt; {
    @Override public void updateItem(T item, boolean empty) {
        super.updateItem(item, empty);

        if (empty) {
            setText(null);
            setGraphic(null);
        } else if (item instanceof Node) {
            setText(null);
            Node currentNode = getGraphic();
            Node newNode = (Node) item;
            if (currentNode == null || ! currentNode.equals(newNode)) {
                setGraphic(newNode);
            }
        } else {
            setText(item == null ? &quot;null&quot; : item.toString());
            setGraphic(null);
        }
    }
}
</pre>
<p>Of course, I&#8217;m not going to leave you with just the code above! We have to make a more useful API out of this (this is my day job after all)! Therefore, borrowing from the style of the cell factories that are shipping with JavaFX 2.2, I present to you the following sample:</p>
<pre class="brush: java; title: ; notranslate">
import javafx.scene.control.ContextMenu;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.util.Callback;

/**
 * A fully fleshed out class that allows for context menus to be shown on right click.
 */
public class ContextMenuListCell&lt;T&gt; extends ListCell&lt;T&gt; {

    public static &lt;T&gt; Callback&lt;ListView&lt;T&gt;,ListCell&lt;T&gt;&gt; forListView(ContextMenu contextMenu) {
        return forListView(contextMenu, null);
    }

    public static &lt;T&gt; Callback&lt;ListView&lt;T&gt;,ListCell&lt;T&gt;&gt; forListView(final ContextMenu contextMenu, final Callback&lt;ListView&lt;T&gt;,ListCell&lt;T&gt;&gt; cellFactory) {
        return new Callback&lt;ListView&lt;T&gt;,ListCell&lt;T&gt;&gt;() {
            @Override public ListCell&lt;T&gt; call(ListView&lt;T&gt; listView) {
                ListCell&lt;T&gt; cell = cellFactory == null ? new DefaultListCell&lt;T&gt;() : cellFactory.call(listView);
                cell.setContextMenu(contextMenu);
                return cell;
            }
        };
    }

    public ContextMenuListCell(ContextMenu contextMenu) {
        setContextMenu(contextMenu);
    }
}
</pre>
<p>Now that we have a simple API, we can proceed to use this API along the following lines:</p>
<pre class="brush: java; title: ; notranslate">
// Create a MenuItem and place it in a ContextMenu
MenuItem helloWorld = new MenuItem(&quot;Hello World!&quot;);
ContextMenu contextMenu = new ContextMenu(helloWorld);

// sets a cell factory on the ListView telling it to use the previously-created ContextMenu (uses default cell factory)
listView.setCellFactory(ContextMenuListCell.&lt;Person&gt;forListView(contextMenu));

// Same as above, but uses a custom cell factory that is defined elsewhere
listView.setCellFactory(ContextMenuListCell.&lt;Person&gt;forListView(contextMenu, customCellFactory));
</pre>
<p>This results in the following when a user right-clicks on a cell in the ListView: </p>
<p><img src="http://fxexperience.com/wp-content/uploads/2012/05/contextMenuListView1.png" alt="" title="contextMenuListView" width="205" height="308" class="aligncenter size-full wp-image-1988" /></p>
<p>However, we&#8217;re left with one final issue: we need a way to determine which cell was selected when a MenuItem action is fired. Fortunately, this proves to be trivial: simply refer to the ListView selection model, as selection also changes on right-click (which in some ways is a bug, but for now it suits our needs). Here&#8217;s some sample code:</p>
<pre class="brush: java; title: ; notranslate">
helloWorld.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
    @Override public void handle(ActionEvent e) {
        System.out.println(&quot;Selected item: &quot; + listView.getSelectionModel().getSelectedItem());
    }
});
</pre>
<p>And that&#8217;s that! <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Hopefully this is helpful to people out there. I&#8217;m sure you&#8217;ll have questions and comments &#8211; feel free to leave them on this post so that others may also learn. </p>
]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/05/listview-custom-cell-factories-and-context-menus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Canned Animations</title>
		<link>http://fxexperience.com/2012/03/canned-animations/</link>
		<comments>http://fxexperience.com/2012/03/canned-animations/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 03:08:17 +0000</pubDate>
		<dc:creator>Jasper Potts</dc:creator>
				<category><![CDATA[Demo]]></category>
		<category><![CDATA[Tips n' Tricks]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1828</guid>
		<description><![CDATA[I found this cool project for web developers this week called Animate.css. It has 52 ready to go animations that you can apply to any dom node. I thought having this for JavaFX would be really handy. We are planning on adding CSS animations to JavaFX in the future along with Web standard CSS properties. [...]]]></description>
			<content:encoded><![CDATA[<p>I found this cool project for web developers this week called <a href="http://daneden.me/animate/" title="Animate.css" target="_blank">Animate.css</a>. It has 52 ready to go animations that you can apply to any dom node. I thought having this for JavaFX would be really handy. We are planning on adding CSS animations to JavaFX in the future along with Web standard CSS properties. Once we do that you will be able to use Animate.css directly in JavaFX but I thought it was too cool to make you wait. So I have written JavaFX Transition classes for each of these 52 animations and put the code for them in the <a href="https://github.com/fxexperience/code" title="Code" target="_blank">FXExperienceControls project</a>. So now all you need to do in your code is:</p>
<pre class="brush: java; title: ; notranslate">
Button btn = new Button(&quot;Button&quot;);
new TadaTransition(btn).play();
</pre>
<p>That will play the animation and clean up after its self. I put together a demo application that shows off all the animations. You can download and run the project <a href="https://github.com/fxexperience/code/tree/master/Blog-Demos/CannedAnimations" title="CannedAnimations github" target="_blank">Blog-Demos/CannedAnimations</a> from our github repo.</p>
<p>Here is what it looks like, enjoy playing with it. I can&#8217;t wait to start using these in the applications I build <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
<a href="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-08-at-7.04.14-PM.png"><img src="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-08-at-7.04.14-PM-300x274.png" alt="" title="CannedAnimations" width="300" height="274" class="aligncenter size-medium wp-image-1829" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/03/canned-animations/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Packaging JavaFX Applications as Native Installers</title>
		<link>http://fxexperience.com/2012/03/packaging-javafx-applications-as-native/</link>
		<comments>http://fxexperience.com/2012/03/packaging-javafx-applications-as-native/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 19:08:35 +0000</pubDate>
		<dc:creator>Jasper Potts</dc:creator>
				<category><![CDATA[Tips n' Tricks]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1786</guid>
		<description><![CDATA[There have been a bunch of questions about how I packaged the FxExperience Tools app. Well this may not be the best way as I have not done this before for Mac and not for Windows for 6 years. So I was learning as I went but here is what I did: Common Considerations Do [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: left;" title="Mac DMG" src="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-02-at-10.21.05-AM.png" alt="" width="219" height="181" /><br />
There have been a bunch of questions about how I packaged the FxExperience Tools app. Well this may not be the best way as I have not done this before for Mac and not for Windows for 6 years. So I was learning as I went but here is what I did:<br />
<span id="more-1786"></span></p>
<h2 style="clear: left;">Common Considerations</h2>
<ul>
<li><strong>Do you include JavaFX?</strong><br />
I would recommend that you do as you do not want your end users to have to think about finding and installing the appropriate version of JavaFX. Also if you want to have an exact version that you have done all your testing on then this is the only way to guarantee it.</li>
<li><strong>Do you include Java JRE?</strong><br />
This is exactly the same as including the JavaFX runtime and has all the same reasons for wanting to do it. For Windows it is a no brainer, just include it. For Mac its a little more complicated at the moment. For 1.6 it should be auto installed for you when needed and you can not redistribute it your self. And when 1.7 is generally available I would recommend packing it in your application.</li>
</ul>
<h2>Application Icon</h2>
<p>You need to design a icon for application and make it in a number of different sizes and formats. I designed ours using Photoshop and created PNG files for each of the common sizes 512&#215;512, 256&#215;256, 128&#215;128, 64&#215;64, 32&#215;32 and 16&#215;16. As the icons gets smaller you will need to tweak/simplify the design so that you can still make out what it is showing when only having a few pixels. Once you have all the PNG files with transparency the next stage is to create a .icns file for Mac and a .ico file for Windows. These are special icon file formats that take all the sizes and combine them into a single file. Apple is very nice in providing a great tool for this in their free XCode tools suite. It is called <strong>Icon Composer</strong> and will take all your images and create both the Mac and Windows icon files for you.<br />
<a href="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-02-at-9.37.06-AM.png"><img class="aligncenter size-medium wp-image-1792" title="Icon Composer" src="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-02-at-9.37.06-AM-300x241.png" alt="" width="300" height="241" /></a></p>
<h2>Mac DMG</h2>
<p>On Mac most applications are shipped as a DMG which is a vertical disk image. Inside of it it contains the Application and a link to the Applications folder so all you have to do to install is Drag and drop. So this is what I created for our FxExperience Tools application so it feels native for Mac users. There are two steps to this process:</p>
<h3>Make Mac Application Bundle</h3>
<p><img style="float: left;" title="JarBundler" src="http://fxexperience.com/wp-content/uploads/2012/03/JarBundler.png" alt="" width="128" height="128" /><br />
For Java 1.6 Apple provides a tool for you called <strong>Jar Bundler</strong> that takes all your jar files and the jar and jnilib files from JavaFX and packages them into a single Application Bundle. On Mac applications are just special kinds of folders that act like a single file. You can right click and go &#8220;Show Package Contents&#8221; to see what is inside any application. Other than adding your files, all you need to do is drag and drop in your icon file and specify the main class. Then click &#8220;Create Application&#8230;&#8221; choose a name and you are done.<br />
<a style="clear: left;" href="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-02-at-9.45.59-AM.png"><img class="aligncenter size-medium wp-image-1795" style="clear: left;" title="Jar Bundler1" src="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-02-at-9.45.59-AM-300x280.png" alt="" width="300" height="280" /></a><a href="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-02-at-9.46.02-AM.png"><img class="aligncenter size-medium wp-image-1796" title="Jar Bundler2" src="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-02-at-9.46.02-AM-300x280.png" alt="" width="300" height="280" /></a></p>
<h3 style="clear: left;">Make DMG Image containing your Application Bundle</h3>
<p><img style="float: left;" title="DFA" src="http://fxexperience.com/wp-content/uploads/2012/03/DFA.png" alt="" width="128" height="128" /> Now that you have your Application Bundle you need to create a zip of DMG so that it can be stored and transmitted by non-macs and over the internet as a single archive. Also it lets you compress it so that it is smaller to download. Although a zip is good enough, a DMG gives you the chance to give your users a nicer experience which is what it is all about on the Mac. So to create a DMG I used the standard Mac tool that comes with every Mac called <strong>Disk Utility</strong>. So launch Disk Utility and click the &#8220;New Image&#8221; button, give it a name and keep the standard options. It will create your disk image and open it in finder as a new disk for you. You can then copy your application bundle into it and also create a alias(mac form of linked file) to the applications folder so that your user has a convenient place to drag your application to. Then for a nicer experience it is recommended that you give the disk window a background picture and make it icon view with the tool bar and side bar turned off.</p>
<p><img class="aligncenter size-full wp-image-1798" title="DMG-Background" src="http://fxexperience.com/wp-content/uploads/2012/03/DMG-Background.png" alt="" width="544" height="408" /><br />
One thing I did learn by mistake is you should put your background image inside your application bundle on the disk image then choose it from there in the view settings dialog. Otherwise it will create a link to it in its absolute location on your machine and will not show on other peoples computers. Last thing then is to size the window to fit your background image and position the window in the center of the screen. Then don&#8217;t close the window, just eject the disk using another finder window. Next you can open your DMG back up in Disk Utility and choose &#8220;Convert&#8221; then save a copy as a compressed format. Then you have your final image ready to ship. When a user opens your DMG they should see something like this:<br />
<img class="aligncenter size-full wp-image-1799" title="Mac DMG" src="http://fxexperience.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-02-at-10.21.05-AM.png" alt="" width="658" height="544" /></p>
<h2 style="clear: left;">Windows</h2>
<p>For windows you need to use a installer maker tool. There are many commercial and free options for this. The one I used is <a href="http://www.ej-technologies.com/products/install4j/overview.html">Install4J from ej-technologies</a>. It is commercial but simple to use and polished. It has the nice ability to be able to generate installers for all platforms from all platforms. So on Windows you can create a Mac installer and on Mac you can create a Windows installer. That is handy if you don&#8217;t have both platforms handy. At $2000 though its a big investment, but if you&#8217;re are shipping a quality application I think it is well worth the investment for the level of polish it offers and the lack of time and hassle of doing your own thing. They do offer free licenses for non-commercial OpenSource projects. I used a old version 3 (the latest is 5) that I had a license for from back when I was running my own startup. I will have to see if I can convince them to gave us a OpenSource license for fxexperience tools project <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . One of the things that it does so well is pack200 and LZMA compressing all the jars that go into the installer. It also makes it very easy to package the JRE inside you application. So for example the windows installer installer is 23Mb download including JavaFX and JRE 1.6 but uncompressed its 100Mb which is very impressive compression. Here is a list of other free windows installer creators that you may want to consider.</p>
<ul>
<li><a href="http://wix.sourceforge.net/">Windows Installer XML (WiX)</a></li>
<li><a href="http://www.jrsoftware.org/isinfo.php">Inno Setup</a></li>
<li><a href="http://nsis.sourceforge.net/Main_Page">NSIS (Nullsoft Scriptable Install System)</a></li>
<li><a href="http://izpack.org">IzPack</a></li>
</ul>
<h3>Bundling JavaFX</h3>
<p>This should be simple with any of these installer tools, all you have to do is include the files from the &#8220;rt&#8221; directory of JavaFX then make sure the javafxrt.jar is in your application class path. Then it should work like magic <img src='http://fxexperience.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>Conclusion</h3>
<p>At the moment this is a little complicated process though using a commercial tool really helps. We would love to be able to provide a tool with JavaFX that makes this super simple but I am not sure when we will be able to commit to it. So this is a great place that the open source community could help with. There are loads of open source projects that do parts of it but nothing that does it all in one simple ant task which is what most developers want. So anyone looking to start a open source project and really help out their fellow developers this would be a great project. I would have a go myself if I had the time. Here are some links to other open source projects that solve parts of the problem. I did not find a free tool that lets you create windows MSI installers on Mac or Linux but feel like someone must have made one.</p>
<ul>
<li><a href="http://informagen.com/JarBundler/">Informagen JarBundler</a></li>
<li><a href="http://www.rkuntz.org/pmwiki.php?n=Code.AntDiskImage">Ant Disk Image</a></li>
<li><a href="http://www.joshondesign.com/2011/09/22/hidden-treasure-appbundler/">App Bundler by Josh Marinacci</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/03/packaging-javafx-applications-as-native/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Customized Segmented ToolBar Buttons</title>
		<link>http://fxexperience.com/2012/02/customized-segmented-toolbar-buttons/</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[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[<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>
]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/02/customized-segmented-toolbar-buttons/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Restricting Input on a TextField</title>
		<link>http://fxexperience.com/2012/02/restricting-input-on-a-textfield/</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[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[<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>
]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/02/restricting-input-on-a-textfield/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>LCD Text support in JavaFX 2.1 Developer Preview</title>
		<link>http://fxexperience.com/2012/01/lcd-text-support-in-javafx-2-1-developer-preview/</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[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[<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>
]]></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>
		</item>
		<item>
		<title>Curve fitting and styling AreaChart</title>
		<link>http://fxexperience.com/2012/01/curve-fitting-and-styling-areachart/</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[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[<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>
]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/01/curve-fitting-and-styling-areachart/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Extending PathBuilder</title>
		<link>http://fxexperience.com/2012/01/extending-pathbuilder/</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[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[<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>
]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2012/01/extending-pathbuilder/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SWT Interop</title>
		<link>http://fxexperience.com/2011/12/swt-interop/</link>
		<comments>http://fxexperience.com/2011/12/swt-interop/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 02:40:51 +0000</pubDate>
		<dc:creator>Richard Bair</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tips n' Tricks]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1549</guid>
		<description><![CDATA[With JavaFX 2.0.2, we&#8217;ve included support for interop with SWT in the same way that we support interop with Swing. That is, you can embed JavaFX within your SWT applications! Although e(fx)clipse has been doing this for a little while by embedding FX -> Swing -> SWT, you can now skip the intermediate embedding into [...]]]></description>
			<content:encoded><![CDATA[<p>With JavaFX 2.0.2, we&#8217;ve included support for interop with SWT in the same way that we support interop with Swing. That is, you can embed JavaFX within your SWT applications! Although e(fx)clipse has been doing this for a little while by embedding FX -> Swing -> SWT, you can now skip the intermediate embedding into Swing and just go straight to SWT. Because FX and SWT share the same basic threading model, this is really easy to do.</p>
<p><a href="http://fxexperience.com/wp-content/uploads/2011/12/SWT-interop.png"><img src="http://fxexperience.com/wp-content/uploads/2011/12/SWT-interop-1024x844.png" alt="" title="SWT-interop" width="655" height="506" class="aligncenter size-large wp-image-1551" /></a><br />
<span id="more-1549"></span></p>
<p>In this code sample, the Table is an SWT table, but the chart is a JavaFX Chart. I create the data model and place it in an ObservableList, and supply this to both the table and the chart. As you edit the table, it ends up also directly manipulating the chart data model, which causes it to animate to the new value.</p>
<pre class="brush: java; title: ; notranslate">
package swt.demo;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.embed.swt.FXCanvas;
import javafx.scene.Scene;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.util.Pair;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;

import com.sun.javafx.runtime.VersionInfo;

/**
*
* @author Richard
*/
public class SWTDemo {
   public static void main(String[] args) {
       Display display = new Display();
       Shell shell = new Shell(display);

       // Print version info
       System.out.println(&quot;SWT &quot; +  SWT.getPlatform() + &quot; &quot; +  SWT.getVersion());
       String runtimeVersion = VersionInfo.getRuntimeVersion();
       System.out.println(&quot;FX &quot; + runtimeVersion);

       shell.setLayout(new FillLayout());

       // Create the fake TabPane guy
       final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
       TabItem chartTab = new TabItem(tabFolder, SWT.NULL);
       chartTab.setText(&quot;JavaFX Chart and SWT Table&quot;);
       TabItem browserTab = new TabItem(tabFolder, SWT.NULL);
       browserTab.setText(&quot;Web Browser&quot;);

       Canvas canvas = new Canvas(tabFolder, SWT.NULL);
       GridLayout layout = new GridLayout(1, true);
       canvas.setLayout(layout);
       chartTab.setControl(canvas);

       // Create the data (I'll use the Chart's data model for
       // both the chart and the table)
       ObservableList&lt;BarChart.Series&gt; bcData = FXCollections.observableArrayList();
       bcData.add(createSeries(new Pair(&quot;2007&quot;, new Double(567)), new Pair(&quot;2008&quot;, new Double(956)), new Pair(&quot;2009&quot;, new Double(1154))));
       bcData.add(createSeries(new Pair(&quot;2007&quot;, new Double(1292)), new Pair(&quot;2008&quot;, new Double(1665)), new Pair(&quot;2009&quot;, new Double(1927))));
       bcData.add(createSeries(new Pair(&quot;2007&quot;, new Double(1292)), new Pair(&quot;2008&quot;, new Double(2559)), new Pair(&quot;2009&quot;, new Double(2774))));

       Canvas chart = createChart(canvas, bcData);
       chart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
       Table table = createTable(canvas, bcData);
       table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
       createTableEditor(table);

       shell.pack();
       shell.open();
       while (!shell.isDisposed()) {
           if (!display.readAndDispatch()) {
               display.sleep();
           }
       }
   }

   private static BarChart.Series&lt;String,Number&gt; createSeries(Pair&lt;String,Double&gt;... values) {
       ObservableList&lt;BarChart.Data&gt; series = FXCollections.&lt;BarChart.Data&gt;observableArrayList();
       for (int i=0; i&lt;values.length; i++) {
           series.add(new BarChart.Data(values[i].getKey(), values[i].getValue()));
       }
       return new BarChart.Series(series);
   }

   private static Canvas createChart(Composite shell, ObservableList&lt;BarChart.Series&gt; bcData) {
       final FXCanvas fxPanel = new FXCanvas(shell, SWT.NONE);
       CategoryAxis xAxis = new CategoryAxis();
       xAxis.setCategories(FXCollections.&lt;String&gt;observableArrayList(&quot;2007&quot;, &quot;2008&quot;, &quot;2009&quot;));
       xAxis.setLabel(&quot;Year&quot;);
       double tickUnit = 1000.0;
       NumberAxis yAxis = new NumberAxis();
       yAxis.setTickUnit(tickUnit);
       yAxis.setLabel(&quot;Units Sold&quot;);
       final BarChart chart = new BarChart(xAxis, yAxis, bcData);
       fxPanel.setScene(new Scene(chart));
       return fxPanel;
   }

   private static Table createTable(Composite parent, ObservableList&lt;BarChart.Series&gt; bcData) {
       Table table = new Table (parent, SWT.BORDER | SWT.HIDE_SELECTION);
       table.setLinesVisible(true);
       table.setHeaderVisible(true);
       String[] titles = {&quot;2007&quot;, &quot;2008&quot;, &quot;2009&quot;};
       for (int i=0; i&lt;titles.length; i++) {
           TableColumn column = new TableColumn (table, SWT.NONE);
           column.setText(titles [i]);
       }
       for (int i=0; i&lt;bcData.size(); i++) {
           createRow(table, bcData.get(i));
       }
       for (int i=0; i&lt;titles.length; i++) {
           table.getColumn (i).setWidth(400/3);
       }
       return table;
   }

   private static TableItem createRow(Table table, BarChart.Series&lt;String,Number&gt; series) {
       TableItem item = new TableItem (table, SWT.NONE);
       item.setData(series);
       int count = 0;
       for (BarChart.Data&lt;String,Number&gt; data : series.getData()) {
           item.setText(count++, data.getYValue().toString());
       }
       return item;
   }

   private static void createTableEditor (final Table table) {
       final TableEditor editor = new TableEditor (table);
       editor.horizontalAlignment = SWT.LEFT;
       editor.grabHorizontal = true;
       table.addListener (SWT.MouseDown, new Listener () {
           public void handleEvent (Event event) {
               Rectangle clientArea = table.getClientArea ();
               Point pt = new Point (event.x, event.y);
               int index = table.getTopIndex ();
               while (index &lt; table.getItemCount ()) {
                   boolean visible = false;
                   final TableItem item = table.getItem (index);
                   for (int i=0; i&lt;table.getColumnCount (); i++) {
                       Rectangle rect = item.getBounds (i);
                       if (rect.contains (pt)) {
                           final int column = i;
                           final Text text = new Text (table, SWT.NONE);
                           final String oldText = item.getText (i);
                           Listener textListener = new Listener () {
                               public void handleEvent (final Event e) {
                                   switch (e.type) {
                                       case SWT.FocusOut:
                                           item.setText (column, text.getText ());
                                           text.dispose ();
                                           break;
                                       case SWT.Traverse:
                                           switch (e.detail) {
                                               case SWT.TRAVERSE_ESCAPE:
                                                   text.setText(oldText);
                                                   //FALL THROUGH
                                               case SWT.TRAVERSE_RETURN:
                                                   item.setText (column, text.getText ());
                                                   text.dispose ();
                                                   e.doit = false;
                                           }
                                           break;
                                       case SWT.Dispose:
                                           if (item.isDisposed() || (text.getText().equals(oldText))) break;
                                           BarChart.Data&lt;String,Number&gt; oldData = ((BarChart.Series&lt;String,Number&gt;)item.getData()).getData().get(column);
                                           try {
                                               double result = Double.parseDouble(text.getText().trim());
                                               oldData.setYValue(result);
                                           } catch (NumberFormatException ex) {
                                               item.setText(column, oldText);
                                           }
                                           break;
                                   }
                               }
                           };
                           text.addListener (SWT.FocusOut, textListener);
                           text.addListener (SWT.Traverse, textListener);
                           text.addListener (SWT.Dispose, textListener);
                           editor.setEditor (text, item, i);
                           text.setText (item.getText (i));
                           text.selectAll ();
                           text.setFocus ();
                           return;
                       }
                       if (!visible &amp;&amp; rect.intersects (clientArea)) {
                           visible = true;
                       }
                   }
                   if (!visible) return;
                   index++;
               }
           }
       });
   }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2011/12/swt-interop/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Styling FX Buttons with CSS</title>
		<link>http://fxexperience.com/2011/12/styling-fx-buttons-with-css/</link>
		<comments>http://fxexperience.com/2011/12/styling-fx-buttons-with-css/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 23:36:03 +0000</pubDate>
		<dc:creator>Jasper Potts</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tips n' Tricks]]></category>
		<category><![CDATA[UI Design]]></category>

		<guid isPermaLink="false">http://fxexperience.com/?p=1523</guid>
		<description><![CDATA[A number of people have asked me recently can I create this look or that look using CSS in JavaFX. Or they have said that you could never do that! So I thought I would do a little experiment and try recreating a bunch of common button styles purely using CSS. So without further ado, [...]]]></description>
			<content:encoded><![CDATA[<p>A number of people have asked me recently can I create this look or that look using CSS in JavaFX. Or they have said that you could never do that! So I thought I would do a little experiment and try recreating a bunch of common button styles purely using CSS. So without further ado, here is the result:</p>
<p><img class="aligncenter size-full wp-image-1524" title="CSS Styled Buttons" src="http://fxexperience.com/wp-content/uploads/2011/12/Screen-Shot-2011-12-20-at-2.51.18-PM.png" alt="" width="706" height="873" /><br />
<span id="more-1523"></span><br />
All of these are mostly created with multiple background fill layers each with a gradient. Then there is a little font tweaking and some subtle effects. So for example all you need to make a JavaFX button look like a Windows 7 button is:</p>
<pre class="brush: css; title: ; notranslate">
#windows7-default {
    -fx-background-color:
        #3c7fb1,
        linear-gradient(#fafdfe, #e8f5fc),
        linear-gradient(#eaf6fd 0%, #d9f0fc 49%, #bee6fd 50%, #a7d9f5 100%);
    -fx-background-insets: 0,1,2;
    -fx-background-radius: 3,2,1;
    -fx-padding: 3 30 3 30;
    -fx-text-fill: black;
    -fx-font-size: 14px;
}
</pre>
<p>The first line defines the 3 background fills, first is solid color and the other two are linear gradients. The background-insets offsets the backgrounds so they do not 100% paint over each other and the second background is 1px in from the outside and the 3rd background is 2px in from the outside of the button. The background-radius us setting the corner radius&#8217;s of the 3 backgrounds getting smaller as the backgrounds move in, this makes the gap between the borders a consistent 1 pixel all the way around. Padding adds extra space around the text to make the button bigger by default. Then the last two lines set the text color and size. That is all there is too it.</p>
<p>I have not included styles for the pressed, over and focused states of all the buttons but they can all be easily added in a similar way. I have included a over and pressed state for the &#8220;Record Sales&#8221; button as a example. </p>
<p>You can download the complete Netbeans project with all the code here.<br />
<b><a href="/applications/ButtonStyles.zip">ButtonStyles.zip</a></b></p>
<p>Here is the CSS code of all the button styles you see above:</p>
<pre class="brush: css; title: ; notranslate">
#green {
    -fx-background-color:
        linear-gradient(#f0ff35, #a9ff00),
        radial-gradient(center 50% -40%, radius 200%, #b8ee36 45%, #80c800 50%);
    -fx-background-radius: 6, 5;
    -fx-background-insets: 0, 1;
    -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.4) , 5, 0.0 , 0 , 1 );
    -fx-text-fill: #395306;
}
#round-red {
    -fx-background-color: linear-gradient(#ff5400, #be1d00);
    -fx-background-radius: 30;
    -fx-background-insets: 0;
    -fx-text-fill: white;
}
#bevel-grey {
    -fx-background-color:
        linear-gradient(#f2f2f2, #d6d6d6),
        linear-gradient(#fcfcfc 0%, #d9d9d9 20%, #d6d6d6 100%),
        linear-gradient(#dddddd 0%, #f6f6f6 50%);
    -fx-background-radius: 8,7,6;
    -fx-background-insets: 0,1,2;
    -fx-text-fill: black;
    -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );
}
#glass-grey {
    -fx-background-color:
        #c3c4c4,
        linear-gradient(#d6d6d6 50%, white 100%),
        radial-gradient(center 50% -40%, radius 200%, #e6e6e6 45%, rgba(230,230,230,0) 50%);
    -fx-background-radius: 30;
    -fx-background-insets: 0,1,1;
    -fx-text-fill: black;
    -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 3, 0.0 , 0 , 1 );
}
#shiny-orange {
    -fx-background-color:
        linear-gradient(#ffd65b, #e68400),
        linear-gradient(#ffef84, #f2ba44),
        linear-gradient(#ffea6a, #efaa22),
        linear-gradient(#ffe657 0%, #f8c202 50%, #eea10b 100%),
        linear-gradient(from 0% 0% to 15% 50%, rgba(255,255,255,0.9), rgba(255,255,255,0));
    -fx-background-radius: 30;
    -fx-background-insets: 0,1,2,3,0;
    -fx-text-fill: #654b00;
    -fx-font-weight: bold;
    -fx-font-size: 14px;
    -fx-padding: 10 20 10 20;
}
#dark-blue {
    -fx-background-color:
        #090a0c,
        linear-gradient(#38424b 0%, #1f2429 20%, #191d22 100%),
        linear-gradient(#20262b, #191d22),
        radial-gradient(center 50% 0%, radius 100%, rgba(114,131,148,0.9), rgba(255,255,255,0));
    -fx-background-radius: 5,4,3,5;
    -fx-background-insets: 0,1,2,0;
    -fx-text-fill: white;
    -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );
    -fx-font-family: &quot;Arial&quot;;
    -fx-text-fill: linear-gradient(white, #d0d0d0);
    -fx-font-size: 12px;
    -fx-padding: 10 20 10 20;
}
#dark-blue Text {
    -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.9) , 1, 0.0 , 0 , 1 );
}
#record-sales {
    -fx-padding: 8 15 15 15;
    -fx-background-insets: 0,0 0 5 0, 0 0 6 0, 0 0 7 0;
    -fx-background-radius: 8;
    -fx-background-color:
        linear-gradient(from 0% 93% to 0% 100%, #a34313 0%, #903b12 100%),
        #9d4024,
        #d86e3a,
        radial-gradient(center 50% 50%, radius 100%, #d86e3a, #c54e2c);
    -fx-effect: dropshadow( gaussian , rgba(0,0,0,0.75) , 4,0,0,1 );
    -fx-font-weight: bold;
    -fx-font-size: 1.1em;
}
#record-sales:hover {
    -fx-background-color:
        linear-gradient(from 0% 93% to 0% 100%, #a34313 0%, #903b12 100%),
        #9d4024,
        #d86e3a,
        radial-gradient(center 50% 50%, radius 100%, #ea7f4b, #c54e2c);
}
#record-sales:pressed {
    -fx-padding: 10 15 13 15;
    -fx-background-insets: 2 0 0 0,2 0 3 0, 2 0 4 0, 2 0 5 0;
}
#record-sales Text {
    -fx-fill: white;
    -fx-effect: dropshadow( gaussian , #a30000 , 0,0,0,2 );
}
#rich-blue {
    -fx-background-color:
        #000000,
        linear-gradient(#7ebcea, #2f4b8f),
        linear-gradient(#426ab7, #263e75),
        linear-gradient(#395cab, #223768);
    -fx-background-insets: 0,1,2,3;
    -fx-background-radius: 3,2,2,2;
    -fx-padding: 12 30 12 30;
    -fx-text-fill: white;
    -fx-font-size: 12px;
}
#rich-blue Text {
    -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.8) , 0, 0.0 , 0 , 1);
}
#big-yellow {
    -fx-background-color:
        #ecebe9,
        rgba(0,0,0,0.05),
        linear-gradient(#dcca8a, #c7a740),
        linear-gradient(#f9f2d6 0%, #f4e5bc 20%, #e6c75d 80%, #e2c045 100%),
        linear-gradient(#f6ebbe, #e6c34d);
    -fx-background-insets: 0,9 9 8 9,9,10,11;
    -fx-background-radius: 50;
    -fx-padding: 15 30 15 30;
    -fx-font-family: &quot;Helvetica&quot;;
    -fx-font-size: 18px;
    -fx-text-fill: #311c09;
    -fx-effect: innershadow( three-pass-box , rgba(0,0,0,0.1) , 2, 0.0 , 0 , 1);
}
#big-yellow Text {
    -fx-effect: dropshadow( one-pass-box , rgba(255,255,255,0.5) , 0, 0.0 , 0 , 1);
}
#iphone-toolbar {
    -fx-background-color: linear-gradient(#98a8bd 0%, #8195af 25%, #6d86a4 100%);
}
#iphone {
    -fx-background-color:
        #a6b5c9,
        linear-gradient(#303842 0%, #3e5577 20%, #375074 100%),
        linear-gradient(#768aa5 0%, #849cbb 5%, #5877a2 50%, #486a9a 51%, #4a6c9b 100%);
    -fx-background-insets: 0 0 -1 0,0,1;
    -fx-background-radius: 5,5,4;
    -fx-padding: 7 30 7 30;
    -fx-text-fill: #242d35;
    -fx-font-family: &quot;Helvetica&quot;;
    -fx-font-size: 12px;
    -fx-text-fill: white;
}
#iphone Text {
    -fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.8) , 0, 0.0 , 0 , -1 );
}
#ipad-dark-grey {
    -fx-background-color:
        linear-gradient(#686868 0%, #232723 25%, #373837 75%, #757575 100%),
        linear-gradient(#020b02, #3a3a3a),
        linear-gradient(#9d9e9d 0%, #6b6a6b 20%, #343534 80%, #242424 100%),
        linear-gradient(#8a8a8a 0%, #6b6a6b 20%, #343534 80%, #262626 100%),
        linear-gradient(#777777 0%, #606060 50%, #505250 51%, #2a2b2a 100%);
    -fx-background-insets: 0,1,4,5,6;
    -fx-background-radius: 9,8,5,4,3;
    -fx-padding: 15 30 15 30;
    -fx-font-family: &quot;Helvetica&quot;;
    -fx-font-size: 18px;
    -fx-font-weight: bold;
    -fx-text-fill: white;
    -fx-effect: dropshadow( three-pass-box , rgba(255,255,255,0.2) , 1, 0.0 , 0 , 1);
}
#ipad-dark-grey Text {
    -fx-effect: dropshadow( one-pass-box , black , 0, 0.0 , 0 , -1 );
}
#ipad-grey {
    -fx-background-color:
        linear-gradient(#686868 0%, #232723 25%, #373837 75%, #757575 100%),
        linear-gradient(#020b02, #3a3a3a),
        linear-gradient(#b9b9b9 0%, #c2c2c2 20%, #afafaf 80%, #c8c8c8 100%),
        linear-gradient(#f5f5f5 0%, #dbdbdb 50%, #cacaca 51%, #d7d7d7 100%);
    -fx-background-insets: 0,1,4,5;
    -fx-background-radius: 9,8,5,4;
    -fx-padding: 15 30 15 30;
    -fx-font-family: &quot;Helvetica&quot;;
    -fx-font-size: 18px;
    -fx-font-weight: bold;
    -fx-text-fill: #333333;
    -fx-effect: dropshadow( three-pass-box , rgba(255,255,255,0.2) , 1, 0.0 , 0 , 1);
}
#ipad-grey Text {
    -fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
}
#lion-default {
    -fx-background-color:
        rgba(0,0,0,0.08),
        linear-gradient(#5a61af, #51536d),
        linear-gradient(#e4fbff 0%,#cee6fb 10%, #a5d3fb 50%, #88c6fb 51%, #d5faff 100%);
    -fx-background-insets: 0 0 -1 0,0,1;
    -fx-background-radius: 5,5,4;
    -fx-padding: 3 30 3 30;
    -fx-text-fill: #242d35;
    -fx-font-size: 14px;
}
#lion {
    -fx-background-color:
        rgba(0,0,0,0.08),
        linear-gradient(#9a9a9a, #909090),
        linear-gradient(white 0%, #f3f3f3 50%, #ececec 51%, #f2f2f2 100%);
    -fx-background-insets: 0 0 -1 0,0,1;
    -fx-background-radius: 5,5,4;
    -fx-padding: 3 30 3 30;
    -fx-text-fill: #242d35;
    -fx-font-size: 14px;
}
#windows7-default {
    -fx-background-color:
        #3c7fb1,
        linear-gradient(#fafdfe, #e8f5fc),
        linear-gradient(#eaf6fd 0%, #d9f0fc 49%, #bee6fd 50%, #a7d9f5 100%);
    -fx-background-insets: 0,1,2;
    -fx-background-radius: 3,2,1;
    -fx-padding: 3 30 3 30;
    -fx-text-fill: black;
    -fx-font-size: 14px;
}
#windows7 {
    -fx-background-color:
        #707070,
        linear-gradient(#fcfcfc, #f3f3f3),
        linear-gradient(#f2f2f2 0%, #ebebeb 49%, #dddddd 50%, #cfcfcf 100%);
    -fx-background-insets: 0,1,2;
    -fx-background-radius: 3,2,1;
    -fx-padding: 3 30 3 30;
    -fx-text-fill: black;
    -fx-font-size: 14px;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://fxexperience.com/2011/12/styling-fx-buttons-with-css/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

