New JavaFX Features

Thursday, September 2, 2010 by Matt Warman
Even though I was critical of the JavaFX's owner, I still think it is a great language that Java development people should consider using. The ability to make ordinary applications special is really cool. The latest version of JavaFX (1.3.1) has been out for a couple of months. I was on assignemt until recently, so I just now have been able to get to the new stuff, and  it is really cool. JavaFX has had CSS in the background, but it was used inconjunction with the making controls Skinnable. It was a bit confusing and tedious, but useful to make your controls pop. That has been replaced with a using CSS to not skin your controls, but creat custom skins too. For Example I wrote this as a splash screen:


The star is a polygon:
var star = Polygon {
        layoutX: 30
        layoutY: 10
    points : [40,10, 48,30, 68,30, 54,44, 62,64, 40,54, 18,64, 26,44, 14,30, 32,30]
    fill: Color.RED
}


With CSS, I can create a star shaped button like this:
#star.button {
     -fx-shape: "M 50,5 L 37,40 5,40 30,60 20,95 50,75 80,95 70,60 95,40 63,40 Z";
     -fx-base: red
}


and use it in my application like this:
var star =  Button {
    id: "star"
    translateX:35
    translateY:30
    layoutInfo: LayoutInfo {
         width: 250
         height: 250
    }
}


it may seem the similar, but by using CSS you can resize and modify the behavior the star. Easy Code resue without "cut and paste".

New Controls

The controls haven't been finalized, but are available to you. Primarily the use of menus and menuItems. This is great for application development folks porting over their old Swing applications. I was really looking forward to these controls, and they don't disapoint. Since I have been using JavaFX, I have been thinking of ways other than menus to present information. I guess its a familiar metaphor for many users, so it is welcome. There is a new Grid container, which is the precursor to a full blown table. It lacks the maturity of a JTable, but allows you to dynamically create rows. You can use the Grid as a Table holder, or just to align labels and text boxes in an input form. The other control I have been using is the ChoiceBox. There has been a swing combobox available, but this is a native control. It uses a checkbox to display your selection in a list. There are still some issues though, as you can only display text, and the list is not editable to the user.

ChoiceBoxes in a Grid Layout

Open Sourcing JavaFX
The issue I have with the ChoiceBox demonstrates the need to open source JavaFX. I can't change the display unless I have access to the source. It is important that application development has access to code for just these situations. There is a petition headed by Steven Chin to do this. Any Application developemnt person who wishes to sign the petition can go here: steveonjava.com/petition-to-open-source-javafx/

Comments for New JavaFX Features

Leave a comment





Captcha