JFXtras 0.5 Release Announcement

22 06 2009

I am pleased to announce the 0.5 release of JFXtras.  This release updates the project with JavaFX 1.2 support, plus includes a major overhaul of the Shapes, Borders, and Layouts.

You can grab the latest bits here:
http://code.google.com/p/jfxtras/downloads/list

And browse the Javadoc online.

Pure JavaFX Shapes

Why should you care that we spent months re-implementing all the Shapes from scratch in pure JavaFX code?  Well, here are a few reasons:

  1. JavaFX 1.2 Compatibility – The JavaFX scene graph was pretty-much rewritten from the ground up in the 1.2 release, so porting the old Shape code was non-trivial.
  2. Mobile Deployment – Yes, you can now draw stars, balloons, and reuleaux triangles on your new HTC Diamond.  (What, you didn’t pick up a JavaFX Mobile device at JavaOne?  Your loss…)
  3. Richard Bair said to do it…  Rich isn’t the sort of guy you say no to, and he was pretty adament about the fact that we shouldn’t be hacking the scene graph directly.  Well, now we aren’t.  (although don’t let him know about our new hack to embed JavaFX in Swing…)

You can try out the new shapes by running the DrawJFXtras sample program from the Pro JavaFX Platform book (which has an entire chapter dedicated to the JFXtras project and other JavaFX FOSS):

Draw JFXtras Sample Application

Draw JFXtras Sample Application

Note:  When playing with the demo be careful using the balloon and rounded rectangle shapes.  They trigger a nasty bounds-detection bug that we still haven’t tracked down.

Thanks to my coworker, Steve Bixby for doing the rewrite in his spare time.  He was looking for a little project to learn JavaFX, and went way above and beyond!

Redesigned Borders

We also redesigned the JFXtras Borders from scratch.  Here are some of the new and noteworthy improvements:

  • Improved performance – The borders render much more quickly, because they take advantage of the new layout infrastructure. This means you can layer and nest borders to your heart’s content without worrying about slow rendering or resizing.
  • Developer-friendly properties – The border properties are still available via CSS, but can now easily be set using variables on the classes as well.
  • Shape-to-Fit support – There is a new property on the border class called shapeToFit that allows you to choose between having the border fill the available width/height or hugging the component.
Jim Clarke's Border Ensemble
Jim Clarke’s JFXtras Border Ensemble

Jim Clarke was responsible for most of this goodness, and did a great blog post that goes into more details here: http://blogs.sun.com/clarkeman/entry/javafx_borders

Layouts Reloaded

What JFXtras release would be complete without at least a partial layout rewrite?  Well, the JavaFX team didn’t leave us much of a choice here, given all the great work they did on layouts in JavaFX 1.2.

The good news is that Amy Fowler and I were mostly on the same wavelength, so the upgrade should be relatively painless.  Here are some of the reasons to use the new JFXtras layout classes:

  • Take advantage of JavaFX 1.2 features – All the JFXtras layouts will honor layoutInfo constraints set on Nodes such as hpos, vpos, and managed.
  • Plus Extended layout features – JFXtras layers fill, span, grow, and full support for resizable layouts.  Simply drop in the ResizableXXX replacement classes (ResizableScene, ResizableHBox, ResizableImageView, etc.) and forget about manual binding of layouts.
  • Plus the JFXtras Defaults System – Most components want to be laid out a certain way.  For example, you usually want Labels left aligned and TextBoxes to grow horizontally.  JFXtras provides defaults for all the new JavaFX 1.2 controls so you don’t have to.
  • And still the best Grids around – The JFXtras Grid and MigLayout have both been fully updated to work with JavaFX 1.2.  Combined together, you have the most powerful layout system available for JavaFX (or any RIA platform) period.

A great way to learn about the JFXtras layouts is by reading Chapter 8 of the Pro JavaFX Platform book.  It goes over a complex MediaExplorer Sample built from the ground up using all the JFXtras layouts from ResizableScene to Grid to MigLayout.

MediaExplorer sample demonstrating JFXtras Layouts
MediaExplorer sample demonstrating JFXtras Layouts

All the Pro JavaFX book samples including DrawJFXtras and MediaExplorer have been open-sourced under the New BSD license as a part of the JFXtras Samples project.  More details on this project will be coming up in the next few weeks.

JavaFX Wrapper for Swing

Amy had a great blog that described how to makeover a JavaFX application by embedding Swing, but how about going the other direction?  With the new SceneToJComponent class, you can do exactly that from a standard API like this:

    public SceneToJComponentTest() {
        String sceneClass = "org.jfxtras.scene.SceneToJComponentScene";
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("FX Panel Test");
        getContentPane().setLayout(new BorderLayout());

        JComponent theScene = SceneToJComponent.loadScene(sceneClass);
        getContentPane().add(new JLabel("JLabel: The following is a JavaFX Scene"), BorderLayout.NORTH);
        getContentPane().add(theScene, BorderLayout.CENTER);

        pack();
    }

This class allows you convert any JavaFX Scene to a Swing JComponent that can be embedded in a larger application, insulating you from future changes in the JavaFX internal APIs.

Full List of Features, Enhancements, and Changes

For existing JFXtras users who want all the gory details that they will need to migrate their applications and take advantage of new features, here it is:

  • JavaFX Wrapper for Swing:
    • The new SceneToJComponent class makes it easy to wrap your JavaFX user interface in a JComponent that you can use from any Swing UI
    • This insulates you from directly calling the JavaFX internal APIs, which may change in any release.
  • JavaFX 1.2 Compatibility:
    • This breaks binary compatibility with old versions.  Please recompile all your code
  • JSONHandler:
    • Enhanced variable name mapping support
  • JFXtras Borders Changes:
    • Border child is now in a parameter called “node” rather than “content”
    • New shapeToFit property to choose between matching the container set width/height or wrapping the nested node
    • Properties are now exposed directly on the border classes in addition to being accessible from CSS.
    • Various border tweaks…  ShapeBorder is now used for clipping, TitledBorder has a line, etc.
  • JFXtras Layout Changes:
    • HAlign/VAlign have been removed in favor of using the new built-in HPos/VPos classes.
    • Fill is not an orthoganal property in its own class used by ExtendedLayoutInfo (which extends LayoutInfo)
    • Grow and span are now on a new GridLayoutInfo class that extends ExtendedLayoutInfo
    • Layout contants are now all in the new LayoutConstants class (formerly GridContraints)
    • ResizableHBox/ResizableVBox have been updated with the new hpos/vpos/nodeHPos/nodeVPos parameters from HBox/VBox
    • ResizableScene now support nodeHPos/nodeVPos parameters
    • Deck now supports nodeHPos/nodeVPos parameters
    • Grid position default is LEFT/MIDDLE
    • Grid now supports nodeHPos/nodeVPos parameters
    • Grid now handles toFront/toBack correctly (and is the only layout in existence that does)
    • New DefaultLayout class for supporting the JFXtras defaults system
    • New JFXContainer class created to support JFXtras layout extensions
    • Removed org.jfxtras.layout.EmptyBorder.  User org.jfxtras.scene.border.EmptyBorder instead.
  • Component Changes:
    • ScrollView now uses JavaFX ScrollBar and ClipView
  • MigLayout Changes
    • MigLayout fixed to make it work with JavaFX 1.2.
    • MigLayout handles dynamic changes to node sizes and their layoutInfo’s managed flag
    • MigLayout code is no longer forked (thanks to nativearrary support in JavaFX!)
  • JFXtras Shapes changes:
    • JFXtras Shapes are now defined as native JavaFX shapes
    • Shapes are generally more fault tolerant to invalid parameter values
    • Almond & Asterisk ‘width’ is now from left to right rather than left-to-center or center-to-right.
    • Asterisk arm width is now as specified (was twice as wide.)
    • ReuleauxTriangle is treated as a spherical object and has centerX, centerY, and radius, rather than x/y/width.
    • All shapes use native JavaFX transforms; specifically, angle of rotation is clockwise rather than counterclockwise as before.
    • All shapes rotate about their bounds center rather than around a starting point – as do all Path-based native JavaFX shapes.

Thanks to the whole JFXtras team, and especially Steve Bixby, Jim Clarke, Dean Iverson, and Keith Combs, for making this release possible.

Enjoy the new JFXtras Release!

Advertisements

Actions

Information

5 responses

16 07 2009
Java desktop links of the week, June 29 | Jonathan Giles

[…] Chin announced the release of JFXtras 0.5, which is a library any JavaFX developer should get to know, as it fills in a lot of gaps that […]

31 08 2009
pj

Hi!

I have one question.
For example i release an application using JFXtras 0.5. What will happen when sun/oracle releases new version of Java that supports future versions of JavaFX (i.e. 1.3)
Will my application crash if user uses new version of Java?

thx for response.

1 09 2009
steveonjava

Existing JavaFX applications will continue to use the version listed in their JNLP file (in your case JavaFX 1.2). Likewise, whatever version of JFXtras you have linked against will continue to be used (in your case JFXtras 0.5), so you are safe in the event of a JavaFX upgrade by Sun.

After a JavaFX release, if you choose to upgrade your application, you would need to upgrade both JavaFX and JFXtras simultaneously. This is because it is almost guaranteed that the next major version of JavaFX will not be binary compatible, so your application and all dependent libraries will need to be updated and recompiled.

I hope this helps clarify!

25 09 2009
ritukar

Hi there!

It was really great to use SceneToJComponent, which enables me to load fx thing in a JComponent, and then can be added in a JFrame.

But my problem is that how can I unload this loaded screen , coz I have load and unload fx screens in a loop.

Waiting for reply eagerly.
Thanks!!

25 09 2009
steveonjava

Please ask this question on the jfxtras users mailing list, and I am sure you will get a quick answer: http://groups.google.com/group/jfxtras-users

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: