About three months ago i have posted an interview with Amy Fowler, one of Sun’s senior engineers working on JavaFX. In that interview i had a question that bothered me ever since the original announcement on JavaFX at last year’s JavaOne – what is its target audience? To my surprise, that question had by far the longest answer in the interview, and i still don’t have a clear answer.

Apart from an understandable wish from a for-profit company trying to break into a lucrative market, it is not immediately clear what is the problem that JavaFX is trying to solve. Before going on a slightly off-topic tangent of the well-designed applications in general, Amy says:

In terms of the general target audience, we obviously have to focus initially on meeting the needs of a specific community, which is the RIA crowd (is anyone else tired of acronyms?). They are clearly less resistant to trying something new, especially when it speeds up development and is built on Java, which has always been about the internet.

Implying that RIA developers are waiting en-masse to try JavaFX as soon as it hits the web just because it is built on Java doesn’t really sound realistic. Outside the “walled garden” of internal development, Java has little weight of excitement as far as the web-based client-facing technologies go. As the recent Sun alumni John O’Conner is finding out, business shops already have an established, proven and ubiquituous alternative solution – Flex and Flash:

I’m learning that web application software teams love Java, but they tend to relegate it to the backend, business logic space. Rich client apps? No way. How about Java Web Start? No need. So, how about just a little, teeny, tiny applet then? Get outta here. Flash, flex, swf files…sure, but no Java on the front end. This particular team won’t even consider Java there. I can’t even begin to argue against Flash at this point.

This brings me back to the topic at hand – what is JavaFX trying to solve? Is it the “boring” internal applications? These are highly unlikely to be rewritten, even if they are written in Swing. The “sexy” flashy browser-embedded content? Adobe has hordes of highly trained designers and developers backed by the extensive tooling and continuous improvements to the platform (including hardware accelerated shaders in Flash 10).

Modularized kernel, applets that can be dragged to the desktop, embedding code samples in the docs, binding and animations built into the language – these are just a few features of JavaFX and 6u10. The word “innovation” pops up in quite a few blogs and articles on JavaFX, and it is a very dangerous word that can easily distract from the end goal – addressing the real world problems. As Scott Berkun writes,

One telling anecdote in my research into innovation history is this striking observation: inventors, creators, and leaders, the people who earned fame for the work other people call innovative rarely used that word themselves. Instead their vocabularies leaned heavily on words like problem, experiment, solve, exploration, change, risk and prototype. Powerful words. Words that are either verbs, or imply a set of actions. And more to the point, they care less about being innovative than they do about making things. Making good things. Forget creating a breakthrough: it’s hard enough to make a really good thing that people will love to use. Most markets are in desperate need of affordable, high quality goods that live up to half the promises their advertising make for them.

The first SDK drop should be out by the end of this month. I hope that “by invitation only” from the (still) horrible javafx.com is just a cheap marketing trick, and we will be able to download it freely without registration of any kind. I hope that we are going to see real applications from real companies. One of these might come from MaldenLabs, as hinted by its CTO in the same exact comment here and here:

We are developing a very large scale enterprise application that will utilize JavaFX. Obviously we considered Flash/Flex and Silverlight, but in the end “bet the farm” and chose JavaFX. We have been pleasantly surprised with the advancement of the language and the unbelievable support and commitment we’ve received from Sun. All I can say is that people are going to be ~very~ surprised.

I also hope that these words would be backed up by replacing the Flash content on that site with a JavaFX-based applet. And finally, I hope that the end product will justify all the time not spent working on Swing.

In the grand scheme of things, it all doesn’t matter. Technologies die, new technologies are born, people move to other companies, old prejudices refuse to die and some decisions are forced on technical people. The customers, of course, couldn’t care less about all this.

Here are some Swing links that you might have missed during this week:

  • Clemens Eisserer continues working on the XRender pipeline for Java2D, and has a few screenshots showing the progress of this project. Part 1, part 2 and part 3 show different test applications under this pipeline.
  • A message from Richard Bair on the mailing list of AppFramework (reference implementation of JSR 296) announces that Alex Potochkin has taken over the ownership of this project. The time indeed has arrived – the last source commit was in October 2007, and while Alex hasn’t posted any message on the mailing list / his blog, i would assume that he is taking his time making himself familiar with the project itself and the JCP / JSR process in general.
  • Alex himself continues writing about the JXLayer project and talks about the internal painting implementation in his latest entry. Jing Ge has a follow up entry in which he builds a complete validation module using BeansBinding, JXLayer and Hibernate Validator.
  • Xavier Young has a short introduction for using the EaSynth look-and-feel.
  • Ethan Nicholas introduces the JavaCSS project that aims to provide CSS support for styling Swing and JavaFX components. While the amount of comments on this entry indicates a significant level of interest in this project, it would be interesting to see how well will it be able to cope with the expectations implied by using the “CSS” in its name. As mentioned by Ben Galbraith in his JavaOne 2006 session, Swing and HTML are sufficiently different in that you can not take the existing “pure” CSS directives and apply them on Swing components. In addition, implementing the layout constructs of CSS may require changing the existing application layout managers. Throw the look-and-feel layer into the mix (don’t forget that the look-and-feel is responsible for computing the inner metrics of Swing components, such as margings, padding, gaps, etc), and you get quite an interesting challenge.
  • Ken Orr writes about unified toolbar buttons in his quest to emulate the appearance of native Mac applications. Surprisingly, this entry features a rather questionable advice on using the SwingUtilities2 class. Not sure about the Apple VM, but this is a strict no-no for even Sun VMs. Not only this class is in an internal sun package, it has also changed location between JDK 5.0 and JDK 6.0. What’s the alternative for SwingUtilities2.drawStringUnderlineCharAt? Call BasicGraphicsUtils.drawStringUnderlineCharAt and install the desktop rendering hints before that.
  • This is most probably will be a part of the next weekly JDK 7 build. Bug 6725214 on forward-porting the new D3D rendering pipeline from 6u10 has been marked as Fix delivered. For the brave souls wishing to venture into the implementation details, follow this Mercurial changeset. No word yet on porting the support for shaped and translucent windows and which package that might end up in.
  • Jacek Furmankiewicz continues working on the Java SwingBuilder project, and this time he writes about adding an SWT-style API for creating menus.
  • And finally, Richard Kennard adds component wiring based on Commons JEXL to his MetaWidget project, aiming at those environments that don’t have expression languages built into the language (such as Swing).

Here are some Swing links that you might have missed during this week:

  • James Williams has a tongue-in-cheek list of five tips to tame Matisse layouts. This resonates with my earlier post on JBuilder and getting locked to an IDE that enforces any non-standard logic on the UI code that it creates.
  • Luan O’Carroll writes about distributing a WebStart application via CD-ROM, expanding on such subjects as WebStart cache, not relying on existing JRE installations, working with no Internet connection and others.
  • Build 27 of 6u10 is out and it addresses the issue that prevented applications from using the Synthetica look-and-feel. It also features performance improvements for Nimbus (about 8% as measured in the dynamic performance suite from the LightBeam project). Although not official, we can expect the release candidate of 6u10 this week.
  • Ken Orr writes about a custom implementation of placard button commonly found in Mac applications.
  • Alexander Potochkin introduces yet another useful feature of his JXLayer project – ability to lock (disable) the entire Swing container, including blocking any user interaction with its children.
  • The “Ask the Experts” session on 6u10 is over, and (much like two years ago), i had a question that was not addressed. I will be polite and blame the intratubes, but the topic at hand will be a subject of a forthcoming entry.

Every once in a while i get questions on using the Mac OS X menu bar for Swing applications running under Substance look-and-feel. This refers to the apple.laf.useScreenMenuBar VM flag that is respected by the native Aqua look-and-feel (and its third-party Quaqua extension). Up until this week the only advice that i could give was to use AWT menus (thanks to Quaqua’s author Werner Randelshofer for this). However, it is not the optimal solution for cross-platform Swing applications that wish to use Swing menus on non-Mac platform.

As i was thinking about this problem after being recently contacted by Sergiy Michka, i thought about an alternative solution which was later reviewed by Swing lead for Apple VM Mike Swingler. The solution is not specific to Substance and should work under other core and third-party look-and-feels that allow mixing menu UI delegates from other look-and-feels. Here is what you can do in your Swing application to have your menus appear on the global menu bar (in addition to setting the above VM flag):

  1. Check that you’re running under Apple VM. Use <font color="darkblue">System.getProperty("os.name")</font> and check that the value starts with “Mac”.
  2. Set Aqua (or the future default Apple VM platform look-and-feel) with <font color="darkblue">UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())</font>.
  3. Query and store the following <font color="darkblue">UIManager</font> entries: “MenuBarUI”, “MenuUI”, “MenuItemUI”, “CheckBoxMenuItemUI”, “RadioButtonMenuItemUI”, “PopupMenuUI”.
  4. Set your look-and-feel of preference with <font color="darkblue">UIManager.setLookAndFeel</font> call.
  5. Before creating your first window, restore the <font color="darkblue">UIManager</font> entries for the keys specified in the third step.

Now the menus on the fronted frame will go into the global menu bar. It is not recommended to rely on the current class names for the Aqua UI delegates, since the package that hosts these classes is different for different versions of Apple VM. This is mentioned in the release notes for Apple VM 1.6.0 on Mac OS X 10.5 Leopard (radar #4907470).