May 13, 2010

September 17, 2009

As I was reading this IntelliJ blog article, I noticed what I thought to be a new JavaFX icon (the Fx text on a black gradient background).

Once I started reading the article, I realized this wasn’t about JavaFX at all, but support for Adobe’s Flex! I guess the lower case “x” in “Fx” should have been a give-away that it wasn’t JavaFX, but I wasn’t paying close attention. That made me wonder, is there a potential marketing conflict here? Could this possibly have been an intentional choice on Adobe’s part, or did Sun choose a bad suffix for Java?

I don’t know any of the history on either side, so I can’t really speculate too much. At any rate, I think there’s some potential for confusion in Adobe’s favor.

June 2, 2009

JavaFX 1.2 arrived silently last night in order to coincide with the opening of JavaOne 2009. I’m happy to see many more UI controls included in this latest release of JavaFX, most notably ScrollBar, which is so painful to re-implement yourself.

Here’s a look at some of the new controls based on a Sun web-start app I found here (run it):Here’s the full list of new UI controls:

Button

Label

CheckBox

ToggleButton

RadioButton

Hyperlink

ProgressBar

ProgressIndicator

Slider

ScrollBar

ListView

TextBox

I wasn’t expecting the controls to have a platform neutral look, though I think this was a good idea (similar to how Adobe Flex controls have an platform agnostic look).

Check out the full JavaFX 1.2 API — note how much fuller it is than in JavaFX 1.1.

I’m interested in hearing you’re thoughts on JavaFX 1.2, specifically about the new UI controls.

March 17, 2009

To aid my exploration of JavaFX I created the following tray-type component (as seen in OS X to display Dashboard widgets). When the disclosure button is pressed, the main content area slides up to reveal a tray area where controls or other information can be placed.

The code is straight-forward, containing a DisclosureButton class (the black cross button) and the main script, which composes the tray, main content area and button. I had to inline quite a bit, as many of the components need to reference other components for visual calculations – I’m still learning what the right balance of declarative syntax is.

I’m not particularly happy with the animation performance on OS X (you’ll notice it’s a bit choppy). Commenting out the main content areas drop shadow eliminates this issue – maybe future Java updates on the Mac will address this problem.

Here are the two states of the window:

You can web start it as well:

And here’s the code (note that I’m not crazy about the way NetBeans formats the code, but I’ve given up fighting with it):

March 14, 2009

If you’re interested in seeing JavaFX support in IntelliJ IDEA (as I am), I encourage you to vote for the feature here. JetBrains has hinted that we’ll see this in IntelliJ IDEA 9, but it can’t hurt to let them know that this is something users really want.

March 5, 2009

I’ve been dabbling with JavaFX script lately and can’t help but notice JavaFX script’s propensity for poor code hygiene. After reading Bob Martin’s Clean Code, I’m hyper aware of code cleanliness. I don’t think there are any fundamental problems with the JavaFX script, only that best practices and good standards have yet to be laid out. I’m sure there was some pretty poor Java code written back in 1995!

Before I go further, let me point out that I think JavaFX script can be just as clean as any other language. I only wish to insight the community to better itself.

Below, I’m going demonstrate how clean JavaFX script can be by transforming some example JavaFX script code that Sun ships with NetBeans into something that better adheres to the principles laid out in Clean Code. You’ll find the original code by downloading NetBeans and selecting File -> New Project, then Samples -> JavaFX -> Building Blocks -> Image -> Background Image. Hopefully the code’s author won’t take offense as none is intended!

In Clean Code, Bob talks about keeping methods small (3 to 4 lines preferably) with a single purpose. Also, he talks about naming variables better in order to eliminate superfluous comments and thus make the code inherently more obvious.