Open Source JavaFX Now!
Using Eclipse to develop JFXtras

NetBeans is a great platform; it's free, it supports Java and JavaFX well, its very up to date when it comes to JavaFX... But is not for me. I've started using Eclipse many winters ago, and it's the platform I know fairly well, it quirks and pleasing points. Maybe one day I'll switch IDE again, even more winters ago it used to be vi, but right now I'm content with Eclipse. 

The question then quickly becomes: how can I use Eclipse to develop JFXtras?

Up until recently the two available plugins, one by Sun and one by Exadel, were not up to par. They were able to edit one JavaFX file, but as soon as you mix in some regular Java or interproject relations they would fail. At then end of 2009 Exadel released a new version and I put it through the paces, but it did not work correctly. However, Exadel was very helpful and with the effort of Max and Alexsandr they got the plugin to a state where it can compile both JFXtras projects in a interproject setup.

2010-01-14: I tested Sun's just released plugin as well, but it at the moment seems to be at the level where Exadel's was two months ago. I will be assisting Sun, probably today, to see if they can get it at this level as well. But at the moment Exadel's is the only one capable of compiling JFXtras.

So, on to business. I'm assuming I'm not talking to newbies, after all we're developing JFXtras here, so I'm leaving out "the obvious". At the time of writing this blog, Exadel's plugin is supposed to become open source, but it isn't yet. And there neither is a Eclipse update site available, so the plugin needs to be downloaded manually from Exadel's website and be unzipped; I did that to C:\tmp\exadel-javafx-plugin-1.2.0. New versions can be unpacked to the same location and Eclipse can then update the plugin; the zip contains the contents of an Eclipse update site, so an online location can't be far away.

Naturally you have to make sure you have Eclipse 3.5+, JavaFX JDK 1.2.1 and a Java environment installed. And then:

Start Eclipse and go to Help -> Install new software...
Click Add...
Enter a name for the plugin, for example "Exadel JavaFX plugin"
Click Local...
Select the directory where the zip was unpacked, INCLUDING the eclipse directory.
 

Press OK
Check the Exadel JavaFX Studio
Press Next
Press Next
Accept the agreement
Press Finish

Wait for all the stuff to be downloaded and restart Eclipse when being asked to do so. Now the plugin is installed. The next step is to setup JavaFX; Exadel's plugin supports multiple versions of JavaFX, just like there can be multiple versions of Java configured in Eclipse.

Goto Window -> Preferences
Select JavaFX
Click Add...
Click Browser... and navigate to the JavaFX JDK directory, just like you would for Installed Java JRE's and click ok.


Click Finish
Click Ok

JFXtras requires the use of some jars that are distributed as part of the JRE. It would be inconvenient to have the path directly in the project's classpath, so at the moment the best option is to add these jars to the classpath of the JRE:

Goto Windows -> Preferences -> Java -> Installed JRE
Select the JRE / JDK that is bound to the JavaSE-1.6 profile, since that is what is setup in the project. Not sure how we are going to do this in the long run, but for now that is how it is set up.
Click Edit
Click Add external JARs...
Navigate to the JRE's home directory, then goto lib, and select deploy.jar and javaws.jar



 

Click Ok, Finish, Ok to close the preferences.

Eclipse is now setup for JFXtras. JFXtras developers can now update the sources and do an "import existing project" twice, once in the common directory and once in control. But for those interested, here are the steps how the projects were created.


 

Goto File -> New... -> Other
Select JavaFX -> JavaFX Project



 

Click Next
Enter the project name "JFXtrasCommon"
Select "Create project from existing source"
Click browse and navigate to the COMMON directory and click Ok.



 

Click Next...
Click Next...
Make sure that both src and test are marked as source folders (via right mouse button).



 

Switch to the 3th tab and remove any jar that is in the dist directory



 

Click finish

The project should compile now, try starting one of the test classes.


 

The next step is to setup the Controls project. But we do not want to simply set that up, but we want to refer directly to the Common project, including its jars. First we need to make sure the common project makes those jars available to related projects:

Right click on JFXtrasCommon and select Properties
Click Java Build path.
Switch to the 4th tab and make sure miglayout and swingutilities are marked as exported.



 

Click Ok

And now the second project must  be created. Since that it largely identicaly to the common project, I'll not include so many screenshots.

Goto File -> New... -> Other
Select JavaFX -> JavaFX Project
Click Next
Enter the project name "JFXtrasControls"
Select "Create project from existing source"
Click browse and navigate to the CONTROLS directory and click Ok.
Click Next...
Click Next...
Make sure both src and test directories are marked as source folders (Right click the "test" directory and select "Mark as source folder" if not).



 

Switch to the 2nd tab and click Add...
Mark JFXtrasCommon and press OK



 

Switch to the 3th tab and remove any jar that is in the dist directory
Click finish

That's it! The project should compile now with only some Java warnings. It is referencing the common project and its exported jars.
Try starting one of the test classes.
 

 

JFXtras Community Site Launched!

jfxtras_portal_mockup_community_version_03

I am proud to announce the official launch of the JFXtras Community Site.  This site is a resource for the entire JavaFX community, and open for participation by all.

Just like the JFXtras open-source library has been helping improve the JavaFX Platform, this site is focused on helping to expand and grow the JavaFX Community.  Some things you can do on the site today include:

Explore -

Boundisizer-screenshot-300

The JFXtras Samples section is the largest JavaFX example repository outside of Sun, and is specifically focused on teaching JavaFX concepts from beginner to advanced.  Some of the featured samples include:

  • Amy Fowler’s Boundisizer – Learn how to transform and manipulate nodes like a champ from Amy Fowler, the acclaimed layout expert on the JavaFX team.
  • Music Explorer FX – You may not have won the 25 thousand dollar prize, but you can learn from the expert.  Sten Anderson has posted his winning entry, and promised to share the full source code shortly (no pressure, Stan!)
  • Particle-O-Rama – Josh Marinacci, JavaFX evangelist and Rockstar1, creates another visual extravaganza with his super-customizable particle demo.
  • Generating Graphs from Hudson – Mark Macumber posted a great mash-up of the JavaFX 1.2 Charting support to display Hudson build status.

The site is completely self-service, and provides free hosting of open-source JavaFX samples, so create an account and start contributing your own samples to grow the community!


1.

Yes, it is official, Joshua Marinacci and I are JavaOne Rockstars!  Josh and I received the JavaOne Rockstar award for having a top ranked JavaOne session this year (thanks to everyone who attended our

WidgetFX Session

!)

Learn -

Through a collaborative effort from all the JavaFX book authors, we will be able to bring you the full set of samples from all 5 of the JavaFX books.  All the source code will be made available under a commercial-friendly open-source license, and the samples will be easily browseable online categorized by topic.

cover-100 JavaFXRIA-cover-100EssentialJavafx-cover-100 JavaFXInAction-cover-100JavaFXDevGuide-cover-100

What is on your bookshelf?

This includes all of the samples from Pro JavaFX Platform, which is finally out in print! — The full realization that I was an author didn’t come until this morning when my copies arrived… for a brief moment the gaping hole in my life for the past six months seemed (almost) worth it.

The Sun JavaFX and Essential JavaFX books have been out since JavaOne and are great references to get started coding in JavaFX.  These samples should be available within the next couple weeks.

Finally, the JavaFX in Action and JavaFX Developer’s Guide books are both due out later this year, and will post samples as soon as it makes sense to.

Research -

jfxtras_portal_mockup_community_version_22

There is also a new section called JFXtras Links brought to you by Jonathan Giles, famous for his weekly desktop links of the week feature on his blog.  The plan is to aggregate and categorize all the best JavaFX links and resources in a single place.

This section is still in its infancy, so please give us feedback and contribute links that you find valuable.

About the Site -

The JFXtras Community Site is built on the principles of collaboration and agility, and is backed by technologies that make this possible.  Everything is 100% Java from the application server (Tomcat) to the portal engine (Liferay).  Also, wherever possible customization and design was done via the online portal user interface so that future changes to the site (both minor and major) can be done by the community.

Most importantly, the JFXtras Community Site will be what you make of it.  Just like everything else we do on the JFXtras project, we are open to new ideas and ways of doing things.  If you have a great idea for how to improve one of the existing sections, or something else we should add to the site, let us know, or better yet, help us make it happen!

JFXtras 0.5 Release Announcement

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:

  1.   
  2.     public SceneToJComponentTest() {   
  3.         String sceneClass = "org.jfxtras.scene.SceneToJComponentScene";   
  4.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);   
  5.         setTitle("FX Panel Test");   
  6.         getContentPane().setLayout(new BorderLayout());   
  7.   
  8.         JComponent theScene = SceneToJComponent.loadScene(sceneClass);   
  9.         getContentPane().add(new JLabel("JLabel: The following is a JavaFX Scene"), BorderLayout.NORTH);   
  10.         getContentPane().add(theScene, BorderLayout.CENTER);   
  11.   
  12.         pack();   
  13.     }  

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.

Enjoy the new JFXtras Release!

JFXtras Core 0.4 Release – Borders, Scrolling, Constraints, JSON Handler, and More!

I am pleased to announce the 0.4 release of the

JFXtras project

.  This is a pretty significant release for the project, which includes quite a bit of new functionality, as well as a new project subdivision.

The JFXtras project has been split into the following three subprojects:

  • JFXtras Core – Contains everything you need to quickly and easily build rich JavaFX applications.  This includes Layouts, UI Controls, Shapes, Borders, Utilities, etc.
  • JFXtras Test – This provides a comprehensive unit and UI test suite along with wrappers for running from the command line or a visual client (coming soon).
  • JFXtras Samples – This is a new project dedicated to providing high quality JavaFX samples to teach the language and bootstrap innovation.  More on this coming in the next few weeks, but if you are interested in contributing or helping out let me know.

The release today is for JFXtras Core, which is now Java 1.5 compatible, and includes some brand new features courtesy of Jim Clarke.  This includes a wide assortment of styleable Borders:

New JFXtras Borders Support

New JFXtras Borders Support

As well as:

  • Styleable ScrollBars and ScrollViews
  • A JSON Handler to automagically populate JavaFX objects from a remote connection

Which is in addition to a whole slew of other cool features including:

  • A new Constraints system for specifying how nodes are laid out with a uniform API
  • Significant updates to the JFXtras Grid
  • New resizable layouts including: ResizableCustomNode, ResizableImageView, ResizableMediaView, ResizableHBox, ResizableVBox, and updates to ResizableRectangle
  • A new version of the Shapes library
  • An ImageFix class that resolves backgroundLoading issues and an ImageUtility class to help with common operations
  • Defect fixes for Shapes, Dialogs, and others

You can download the latest bits here:  http://code.google.com/p/jfxtras/downloads/list.  And also browse the online Javadocs.

Thanks to the whole JFXtras crew for putting together another huge release!

Showing 4 results.
Recent Bloggers Recent Bloggers
Tom Eugelink Posts: 1
Stars: 1
Date: 1/14/10
Stephen Chin Posts: 3
Stars: 0
Date: 7/21/09