Posted by emilian
on February 6, 2008 at 5:02 AM PST
The XHTML rendering library called Flying Saucer is available in the NetBeans 6.0 Platform. It's not public yet but friend of the CSS Visual module. Though that doesn't mean we can't use it !
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();
//create the panel
XHTMLPanel p = new XHTMLPanel();
//set the contents to a file
//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.