Skip to main content

FlyingSaucer in NetBeans Platform suites

Posted by emilian on February 6, 2008 at 5:02 AM PST

XHTML Renderer library provides us with way better looking HTML pages which can easily replace some of the Swing displays or make nice "preview" panels.

Furthermore, being included in the Platform, it's just a few clicks away to actually use it.

The only problem so far is that it only provides public packages for the friend module Visual CSS.

But, that can't stop a determined mind. We can add a dependency on the implementation version of the module and thus become a "friend" and have access to all the public packages.

Note: The downside is that if the version changes you'll have to rebuild the module.

So, first we just create a module suite with the platform and ide clusters:


And from the ide cluster we just use the Flying Saucer XML Renderer module:


Here comes the trick: click on the Edit... button after you've selected the module in the Module dependencies list and tick Implementation version.


We are almost set. All we need now is create the XHTMLPanel:

 //quickly create a TopComponent (kinda bad in practice ;) )
TopComponent tc = new TopComponent();
tc.setLayout(new BorderLayout());

//create the panel

XHTMLPanel p = new XHTMLPanel();

//set the contents to a file

p.setDocument(new File("/path/to/your/file/index.xhtml"));

//add the panel and show it

And that was it:


This also allows you to make really fast a welcome screen. Just brush up those CSS skills.

Related Topics >>


Are there plans to make the Flying Sacuer module public? I think the welcome screen should use it. I just went through the process of trying to bhange the welcome screen module for my platform app, and the Swing code it is built with is crazy. It would be much easier to use if it used Flying Saucer.