Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

A Look at WebRenderer Swing Edition 5.0

DZone's Guide to

A Look at WebRenderer Swing Edition 5.0

· Java Zone
Free Resource

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

WebRenderer still claims the privilege of being the world’s first and only standards compliant, pure Swing embedded Java browser SDK.  With the recent release of WebRenderer Swing Edition 5.0, JadeLiquid Software continues its mission to improve the displays of rich client-side Java content on the web.  Along with Firefox 3.x support and new performance, security, memory, and graphics improvements, WebRenderer Swing Edition 5.0 continues to provide unique benefits for Java developers.

WebRenderer is built on Firefox 3.x and it supports IE and Safari as well.  Version 5.0's new JavaScript rendering engine has gotten major performance improvements along with better speed and memory performance.  Security and the Graphics Library also received improvements.  WebRenderer is aimed at addressing the fact that default HTML support in Swing has not kept up with today's browser standards.  While other tools solve this problem by embedding native OS browser components inside Java, WebRenderer avoids the requirement of having the prerequisite browser properly installed because their implementation is pure Swing.  

Pure Swing also allows support for features like Flash, CSS, and DHTML without having to install native browser support on the destination OS.  There is also a SSL Certificate interface, plugins such as Java Applets, and W3C DOM (including level 2).  WebRenderer combines the rendering quality of Firefox with Swing's lightweight drawing.  This includes support for Swing dialogs, components, and Java Look and Feels.  The WebRenderer architecture provides solid integration into Swing applications with Mozilla's content rendering and standards compliance in order to give Swing commercially legitimate web content rendering.

WebRenderer Supports:


Creating a WebRenderer Browser

To create a WebRenderer browser with WebRenderer add the following:


//Core call to enable the 30 day trial

BrowserFactory.setLicenseData("username", "serial");

//Creating the browser instance

IBrowserCanvas browser = BrowserFactory.spawnMozilla()
You can also spawnInternetExplorer() or spawnSafari().  Here is how you create the JPanel:
public JPanel browserPanel(){
   JPanel panel = new JPanel(new BorderLayout());
   IBrowserCanvas browser = BrowserFactory.spawnInternetExplorer();
   panel.add(BorderLayout.CENTER, (IEBrowserCanvas)browser);
   return panel;
}
JPanel includes a layout manager (BorderLayout) that expands to the size of the JPanel and properly suites the browser. IBrowserCanvas is WebRenderer's main Interface and it has many useful functions. To create an IBrowserCanvas object, just use the call: BrowserFactory.spawnInternetExploerer or BrowserFactory.spawnMozilla(). 



Next, the browser is cast to an IEBrowserCanvas class inheriting from Canvas that makes WebRenderer a component and adds it to the panel in the Center.  The browser is added to the Center in order to use up the sized panel's remaining space and the panel is returned to the calling function.  WebRenderer can also be cast to a standard Canvas like the one shown below:
Canvas canvas = (Canvas)browser;
Canvas canvas = (Canvas)browser;
WebRenderer DOM
The WebRenderer DOM is a large tree-like structure that allows you to access the underlying document.  A large number of various size elements have to be populated, so DOM methods must be called after the NetworkEvent onDocumentComplete has fired. Be aware that calling DOM methods like IBrowserCanvas getDocument before onDocumentComplete may return a DOM document that is not fully populated.  Here's an example of the WebRenderer DOM:
browser.addNetworkListener(new NetworkAdapter() {
public void onDocumentComplete(NetworkEvent e) {
// Get the DOM Document
IDocument document = browser.getDocument();
}
});
WebRenderer's website includes more code examplesAPI documentation, and a developer's guide.

Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}