FX Experience Has Gone Read-Only

I've been maintaining FX Experience for a really long time now, and I love hearing from people who enjoy my weekly links roundup. One thing I've noticed recently is that maintaining two sites (FX Experience and JonathanGiles.net) takes more time than ideal, and splits the audience up. Therefore, FX Experience will become read-only for new blog posts, but weekly posts will continue to be published on JonathanGiles.net. If you follow @FXExperience on Twitter, I suggest you also follow @JonathanGiles. This is not the end - just a consolidation of my online presence to make my life a little easier!

tl;dr: Follow me on Twitter and check for the latest news on JonathanGiles.net.

Extending PathBuilder

I came across the interesting blog “JavaFx and HTML5 differences” 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

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));

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?

Code with new Builder

Path path4 = PathBuilderExtended.create()
        .moveTo(50, 50)
        .lineTo(150, 50)
        .lineTo(150, 150)
        .lineTo(50, 150)
        .closePath()
        .strokeWidth(2)
        .stroke(Color.RED)
        .build();

This seemed a lot cleaner and simpler to read. I have filed a feature request RT-19266 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.

Fun JavaFX 2.0 Audio Player

Fun JavaFX 2.0 Audio Player

I was inspired by Dean Iverson’s tweet with a audio equalizer in JavaFX:

#JavaFX rocks. Literally. An example from our upcoming Pro JavaFX 2 book: pic.twitter.com/tSI4Vry4
and the equalizer view from that Pro JavaFX 2 example app: pic.twitter.com/T6jxvrf9
. updated pic.twitter.com/FqzgVimG

So wanted to have a go at doing one my self, so little while later I have a design and built a working application. Demo video after the break.

(more…)

FXG to FXML in JavaFX

FXG to FXML in JavaFX

When Eileen and I were working on our session for JavaOne on Designer-Developer workflow we needed a way of converting some vector graphics from Adobe Illustrator into JavaFX. So I tried the FXG to JavaFX converter I found on the web and did not have much luck as what Eileen and draw was pretty advanced. So I thought well FXG is a XML file and FXML is a XML file and as I used to do XML->XML conversion all the time for a previous job using XSLT. I thought how hard can be be to write a converter, well about 4 hours later and some dusting off of The XSLT book here is what I came up with:


(more…)

Styling FX Buttons with CSS

Styling FX Buttons with CSS

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:


(more…)

JavaFX sessions at JavaOne 2011 online

The audio + slides for many of the JavaFX sessions at JavaOne 2011 are available on parleys.com. I have embedded a few we recommend you watch. There will be more arriving on parleys.com over the next couple weeks as they get processed.

Introduction to JavaFX :: Nicolas Lorain

JavaFX Architecture :: Richard Bair

JavaFX Architecture II :: Richard Bair