XHTML/CSS Rendering In Swing

Joshua Marinacci, whom I worked with when I was at Sun, is in the Bay area this week and we had dinner together tonight. He told me more about Flying Saucer, a project he’s been working on for a few years now.

Flying Saucer is an XHTML/CSS renderer written in pure Java that can be easily embedded in Swing applications. The latest version, R7, is quite impressive. The support for XHTML and CSS 2.1 is great and the rendering very fast. I was particularly surprised by the quality of the rendering of filthyrichclients.org, which caused many troubles to IE, Firefox and Safari:

Filthy Rich Clients in Flying Saucer

Flying Saucer can do much more, like PDF and SVG rendering. While it would be foolish to write a full-fledged web browser upon this library, this project is extremely interesting and useful for regular desktop applications. Writing help screens or even complicated layouts becomes so much easier with Flying Saucer. The ability to embed any Swing component within a web page leads to countless wonderful user interfaces.

9 Responses to “XHTML/CSS Rendering In Swing”

  1. Patrick Wright says:

    Thanks for the write-up and passing the recommendation along. I love that screenshot as well–it’s been hard for me to find really good-looking sites that are XHTML compliant (or compliant enough)–if it’s OK with you, I’d love to use your book’s (current) site among our screenshots.

    Two other quick comments–you can generate images as well, and SWT output should be in the next release, we have some patches in the chain for it already.

    Thanks very much for the nice comments, the team appreciates it
    Patrick
    Flying Saucer

  2. Magnus Falk says:

    Try the filthyrichclients site with Opera, looks very nice!

  3. Romain Guy says:

    You’re very welcome Patrick. You guys did all the hard work, you deserve some kudos :) And sure, you can use the screenshot.

    Magnus: It also looks very good in Opera Mini 4 beta on my cell phone :)

  4. Shai Almog says:

    The demos are far more impressive than the last time I checked. The speed is amazingly good and not many rendering “artifacts”.
    This looks like a great tool with a huge potential.

  5. Laird Nelson says:

    Hey, Romain; do you have specific reasons for saying it would be foolish to write a browser on top of this library? I can think of lots of problems to overcome, of course, but is there some underlying limitation that you’re aware of inside Flying Saucer that makes it a particularly bad choice for this?

  6. Romain Guy says:

    Laird, sure. First of all, Flying Saucer is fast, but not enough to be used on “real world” web pages (for instance, images are are not downloaded in background threads.) Although, FS can only render pure XML/XHTML web pages, thus making most web pages out there impossible to render. FS uses Tidy to try to fix the XML issues it finds in pages, but it’s not enough to ensure you can visit your favorite web sites. Then the lack of JavaScript is also a big hindrance nowadays.

  7. Laird Nelson says:

    Thanks for the response; now I see where you’re coming from.

  8. Tristan Seifert says:

    This is so cool! I bet I can make my jTunes use this for the store. And if not, I can still do cool stuff with it, I suppose? And it said ‘can render any swing component’ on their website, how can I embed custom components?