Over a million developers have joined DZone.

Sneaking a Peek at JavaFX 2.1 Beta

DZone 's Guide to

Sneaking a Peek at JavaFX 2.1 Beta

· Java Zone ·
Free Resource

It was announced earlier this month that the JavaFX 2.1 Developer Preview Edition (early access) for Windows is available for download (previously available for Mac). In the post JavaFX 2.1 early access for Windows (build 06) now available, Jonathan Giles writes as a feedback comment that this new version of JavaFX includes "new charts and a new ComboBox control." He also points out that "there isn’t a public list of highlights yet." Not being known for my patience, I couldn't resist taking a peek at JavaFX 2.1 to see what nice surprises lie in store.

One quick and dirty method I like for a first cut at looking at changes in APIs is to run my simple Groovy script diffVersionsJavadocs.groovy against two versions of Javadoc. The latest version of this simple script is shown next.

#!/usr/bin/env groovy
// diffVersionsJavadocs.groovy
// This simplistic script compares two versions of online Javadoc documentation
// to identify new or removed constructs from one version to the other.
// Example comparing Guava Release 10 to Guava Release 11:
// Guava Release 10:
//    http://docs.guava-libraries.googlecode.com/git-history/v10.0.1/javadoc/allclasses-noframe.html
// Guava Release 11:
//    http://docs.guava-libraries.googlecode.com/git/javadoc/allclasses-noframe.html
// Example comparing JavaFX 2.0 to early access version of JavaFX 2.1 (Windows)
// JavaFX 2.0:
//    http://docs.oracle.com/javafx/2.0/api/allclasses-noframe.html
// JavaFX 2.1 (Early Access)
//    file:///C:/javafx-2_1-api/allclasses-noframe.html 

if (args.length < 4)
   println "\nUSAGE: diffVersionsJavadocs first_label first_url second_label second_url"
   println "\n\twhere first_label is name of first version"
   println "\t      first_url is URL of Javadoc for first version (usually allclasses-noframe)"
   println "\t      second_label is name of second version"
   println "\t      second_url is URL of Javadoc for second version (usually allclasses-noframe)"
@Grab(group='org.ccil.cowan.tagsoup', module='tagsoup', version='0.9.7')

def firstXml = new XmlParser(new org.ccil.cowan.tagsoup.Parser()).parse(args[1])
def firstUrls = firstXml.'**'.a.@href
def firstLabel = args[0]

def secondXml = new XmlParser(new org.ccil.cowan.tagsoup.Parser()).parse(args[3])
def secondUrls = secondXml.'**'.a.@href
def secondLabel = args[2]

compareSetsOfStrings(secondUrls, secondLabel, firstUrls, firstLabel)

 * Compare first Collection of Strings to second Collection of Strings by
 * identifying which Strings are in each Collection that are not in the other.
 * @param firstStrings First Collection of Strings to be compared.
 * @param firstLabel Name of first collection of Strings.
 * @param secondStrings Second Collection of Strings to be compared.
 * @param secondLabel Name of second collection of Strings.
def void compareSetsOfStrings(
   Collection<String> firstStrings, String firstLabel,
   Collection<String> secondStrings, String secondLabel)
   println "Constructs in ${firstLabel} But Not in ${secondLabel}"
   def firstButNotSecond = firstStrings - secondStrings

   println "Constructs in ${secondLabel} But Not in ${firstLabel}"
   def secondButNotFirst = secondStrings - firstStrings

 * Print the provided Strings one per line indented; prints "None" if the
 * provided List of Strings is empty or null.
 * @param strings The Strings to be printed
def void printIndentedStrings(Collection<String> strings)
   if (!strings?.isEmpty())
      new TreeSet(strings).each
         println "\t${it}"
      println "\tNone"

In this case, I was not able to find the JavaFX 2.1 API documentation publicly available online, so I downloaded the Windows Developer Preview and used the local JavaFX 2.1 API documentation that is included in the download to compare with the publicly available JavaFX 2.0 API documentation. I ran the script as shown in the next screen snapshot.

For convenience and "searchability" purposes, I have included the script's output as text next. The top section shows what I was mostly interested (new constructs in JavaFX 2.1), but the lower section is interesting because there are a surprising number of constructs that were in JavaFX 2.0 Javadoc that are no longer (at least as of now) in teh JavaFX 2.1 Javadoc.

  • Constructs in JavaFX 2.1 But Not in JavaFX 2.0
    • javafx/beans/WeakListener.html
    • javafx/collections/ObservableSet.html
    • javafx/collections/SetChangeListener.Change.html
    • javafx/collections/SetChangeListener.html
    • javafx/collections/WeakListChangeListener.html
    • javafx/collections/WeakMapChangeListener.html
    • javafx/collections/WeakSetChangeListener.html
    • javafx/concurrent/WorkerStateEvent.html
    • javafx/scene/ParentDesignInfo.html
    • javafx/scene/chart/StackedAreaChart.html
    • javafx/scene/chart/StackedAreaChartBuilder.html
    • javafx/scene/chart/StackedBarChart.html
    • javafx/scene/chart/StackedBarChartBuilder.html
    • javafx/scene/control/ComboBox.html
    • javafx/scene/control/ComboBoxBase.html
    • javafx/scene/control/ControlDesignInfo.html
    • javafx/scene/control/SplitPaneDesignInfo.html
    • javafx/scene/input/ContextMenuEvent.html
    • javafx/scene/input/MouseDragEvent.html
    • javafx/scene/layout/GridPaneDesignInfo.html
    • javafx/scene/layout/PaneDesignInfo.html
    • javafx/stage/DirectoryChooser.html
    • javafx/stage/DirectoryChooserBuilder.html
  • Constructs in JavaFX 2.0 But Not in JavaFX 2.1
    • javafx/concurrent/ServiceBuilder.html
    • javafx/event/EventBuilder.html
    • javafx/event/EventTypeBuilder.html
    • javafx/scene/chart/AxisBuilder.html
    • javafx/scene/chart/CategoryAxisBuilder.html
    • javafx/scene/chart/NumberAxisBuilder.html
    • javafx/scene/chart/ValueAxisBuilder.html
    • javafx/scene/control/AccordionBuilder.html
    • javafx/scene/control/ButtonBaseBuilder.html
    • javafx/scene/control/ButtonBuilder.html
    • javafx/scene/control/CellBuilder.html
    • javafx/scene/control/CheckBoxBuilder.html
    • javafx/scene/control/CheckMenuItemBuilder.html
    • javafx/scene/control/ChoiceBoxBuilder.html
    • javafx/scene/control/ContextMenuBuilder.html
    • javafx/scene/control/ControlBuilder.html
    • javafx/scene/control/CustomMenuItemBuilder.html
    • javafx/scene/control/HyperlinkBuilder.html
    • javafx/scene/control/IndexRangeBuilder.html
    • javafx/scene/control/IndexedCellBuilder.html
    • javafx/scene/control/LabelBuilder.html
    • javafx/scene/control/LabeledBuilder.html
    • javafx/scene/control/ListCellBuilder.html
    • javafx/scene/control/ListViewBuilder.html
    • javafx/scene/control/MenuBarBuilder.html
    • javafx/scene/control/MenuBuilder.html
    • javafx/scene/control/MenuButtonBuilder.html
    • javafx/scene/control/MenuItemBuilder.html
    • javafx/scene/control/MultipleSelectionModelBuilder.html
    • javafx/scene/control/PasswordFieldBuilder.html
    • javafx/scene/control/PopupControlBuilder.html
    • javafx/scene/control/ProgressBarBuilder.html
    • javafx/scene/control/ProgressIndicatorBuilder.html
    • javafx/scene/control/RadioButtonBuilder.html
    • javafx/scene/control/RadioMenuItemBuilder.html
    • javafx/scene/control/ScrollBarBuilder.html
    • javafx/scene/control/ScrollPaneBuilder.html
    • javafx/scene/control/SeparatorBuilder.html
    • javafx/scene/control/SeparatorMenuItemBuilder.html
    • javafx/scene/control/SliderBuilder.html
    • javafx/scene/control/SplitMenuButtonBuilder.html
    • javafx/scene/control/SplitPaneBuilder.html
    • javafx/scene/control/TabBuilder.html
    • javafx/scene/control/TabPaneBuilder.html
    • javafx/scene/control/TableCellBuilder.html
    • javafx/scene/control/TableColumnBuilder.html
    • javafx/scene/control/TablePositionBuilder.html
    • javafx/scene/control/TableRowBuilder.html
    • javafx/scene/control/TableViewBuilder.html
    • javafx/scene/control/TextAreaBuilder.html
    • javafx/scene/control/TextFieldBuilder.html
    • javafx/scene/control/TextInputControlBuilder.html
    • javafx/scene/control/TitledPaneBuilder.html
    • javafx/scene/control/ToggleButtonBuilder.html
    • javafx/scene/control/ToggleGroupBuilder.html
    • javafx/scene/control/ToolBarBuilder.html
    • javafx/scene/control/TooltipBuilder.html
    • javafx/scene/control/TreeCellBuilder.html
    • javafx/scene/control/TreeItemBuilder.html
    • javafx/scene/control/TreeViewBuilder.html
    • javafx/scene/control/cell/PropertyValueFactoryBuilder.html
    • javafx/util/PairBuilder.html

We can see from the output above that there is, as of now, a new DirectoryChooser, the already-mentioned new ComboBox control, two new chart types (StackedBarChart and StackedAreaChart), and several new collections listeners. The long list of constructs that are no longer part of JavaFX (as of now for JavaFX 2.1) are all, probably not coincidentally, "builders." UPDATE: Jonathan has pointed out the "builders" are actually in JavaFX 2.1 and were only omitted at one time from the JavaFX 2.1 Javadoc documentation. Based on this, I have striked-out that portion of the output above.

The Jonathan Giles post warns that this early access beta release of JavaFX 2.1 should not be used for production systems, but it is interesting to get a glimpse of what is to come. Perhaps as important as the new features and classes themselves is the fact that updates are occurring.


From http://marxsoftware.blogspot.com/2011/12/sneaking-peek-at-javafx-21-beta.html


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}