Creating and using a WebRenderer browser instance






When working with a WebRenderer browser the two core interfaces are BrowserFactory and IBrowserCanvas.













Because BrowserFactory spawns instances of the requested browser, BrowserFactory is used to setup the library path (if the WebRenderer platform optimized JAR files are not in the CLASSPATH) The BrowserFactory also manages the license key for WebRenderer.

Key methods in BrowserFactory:

setLibraryPath(String path)
setLibraryPath(File directory)
setMozillaPath(String path)
setMozillaPath(File directory)

If the WebRenderer JAR files are not in the CLASSPATH the library path must be set to the location of the WebRenderer libraries, specifically the webrenderer-xxx.jar (xxx denotes the platform prefix such as win, solaris, linux, osx) and the corecomponents-xxx.jar. The webrenderer-xxx.jar and corecomponents-xxx.jar can be placed in different directories but if the corecomponents-xxx.jar are in a different directory the setMozillaPath  and setLibraryPath methods must be called to point WebRenderer to their location.

WebRenderer library search order (if library found searching stops):















The webrenderer.jar must always be in the Java CLASSPATH.

Example (Windows):

java -cp webrenderer.jar;. TestBrowser

Linux, OSX and Solaris:

java -cp webrenderer.jar:. TestBrowser

setLicenseData(String username, String serial)

The setLicenseData method is essential to receive full WebRenderer functionality. This method must be called before a browser is spawned. If the license information is not set a dialog will display notifying you and some WebRenderer functionality will be disabled.














loadURL() - The WebRenderer loadURL method is core to loading pages into WebRenderer. The loadURL method can take a URL as a Java String or a java.net.URL.

loadHTML() - WebRenderers loadHTML is the mechanism used to load HTML and web content into WebRenderer through Java Strings, InputStreams and as Bytes. The loadHTML method takes a base reference as a parameter.

Example usage:

browser.loadHTML("<HTML><B>Hello World</B></HTML>", "");

If an empty base reference is passed to the loadHTML method then the base directory will be the directory the application is loaded from. If there are relative references to images, javascript, css etc WebRenderer will search for these in the base reference. The base reference can be a remote URL, it does not necessarily have to be on a local disk. If the base reference is set to a remote URL then WebRenderer will load the resources relative from the passed URL as requested by the document loaded.

When adding an IBrowserCanvas to a JPanel or
equivalent it must be cast to a Canvas. This can be done by calling the following:


After WebRenderer is cast to a Canvas it can be added to a graphical layout.

setProxy(ProxySetting protocol, String proxyAddress, int port) - The setProxy method allows the user to set a proxy server. The proxy server can be an authenticated proxy. For the proxy settings to take effect the IBrowserCanvas enableProxy method must be called. The proxy can be disabled via the disableProxy method.

Example usage:

browser.setProxy(ProxySetting.PROTOCOL_HTTP, "my.proxy.com", 8080);



 Copyright � JadeLiquid Software - www.jadeliquid.com