Tuesday, April 06, 2010

Visual Tail in JavaFx

Having recently decided to try and learn something about JavaFX, I decided to port my Visual Tail application which was done using Griffon/Swing to run using JavaFX.

Overall the process was pretty smooth, but here were some of the parts that caused me a bit of grief.

Component Layout

Initially I had a hard time with laying out my components in JavaFX.

I was used to Swing based layouts so I was looking for a layout manager to take care of this for me. While there are some basic layout capabilities (HBox, VBox, etc..) in JavaFX there is nothing built into it that is quite like the Swing layout managers, in particular MigLayout.

NOTE** There is capability to use MigLayout in JavaFX, but it is through an add-on to JavaFX. Link.

After a bit of reading, I found that basic layouts are typically done by using binding, which worked great for my simple application.

Background Tasks

It also took a minute to figure out how to make something run as a background task. For reference I ended up extending the javafx.async.JavaTaskBase class which worked just fine.

Lack of Components

My only other sticking point was with the minimal set of of native JavaFX components. There are still some of the components that are missing like a drop down box and a multi-line text area.

For my application the problem was with the lack of a multi-line text area.

However this was not really a big deal and there is a simple solution. Just extended the javafx.ext.swing.SwingScrollableComponent and created a wrapper around a Swing JTextArea component. You can then use that in your JavaFx code.

Final Product

So after a bit of work, here is the final product.

Java WebStart: link
Java Applet: link

UPDATE - 4/7/2010

Thanks to my visitors for pointing out the problem with the JNLP files. I had forgot to change the "codebase" location. Should be fixed now.


Anonymous said...

You need to fix up the applet and webstart links, as they contain references to your local machine (e.g. /Users/daniel/NetBeansProjects/VisualTail/dist/VisualTail.jnlp).

-- Jonathan

Sergey Surikov said...

com.sun.deploy.net.FailedDownloadException: Unable to load resource: file:/Users/daniel/NetBeansProjects/VisualTail/dist/VisualTail.jnlp

fix base tag in your jnlp

Rusty Myers said...

Seems to be working well on my OS X 10.6 work box. Nice man!