|
Lobo Browser API
This page explains how to use the Lobo browser
JAR files as an API. We provide this API so that Swing applications that require
web browser functionality can embed Lobo.
Requirements
The Browser API requires J2SE 5+ (JRE 1.5+). Direct
JavaFX rendering
in Lobo requires JRE (not JDK) 1.6+ at runtime.
Lobo vs. Cobra
The Cobra library and its dependencies are in
charge of HTML and CSS parsing, rendering, plus Javascript processing – and not much else.
Lobo, on the other hand, is a browser application
that has been documented so that it can be used as an API.
The Lobo browser API relies on the capabilities of Cobra as far as
HTML is concerned. What the Lobo browser API provides are browser
capabilities that are not HTML specific. These include:
- Rendering content that is not necessarily HTML, such as images, text,
JavaFX,
Java,
and any other content renderable via plugins.
- A web request and HTTP engine supporting such features as
HTTP authentication, HTTPS, cookies, caching, etc.
- A navigation infrastructure.
Cobra, for the most part, expects developers to implement these features as they prefer,
whereas
Lobo implements them in specific ways (e.g. saving cached documents
in $HOME/.lobo and so forth).
Cobra should be a more suitable solution in the following scenarios:
- Only HTML parsing or simple rendering without browser-style
navigation is required.
- The developer wishes to have full control over how browser features
are implemented and configured.
- The developer requires a more compact framework.
API Documentation
JavaDoc for the Browser API may be found in the
Lobo Browser API Documentation page.
Additionally, the Lobo Clientlet and Extensions API Documentation page
can prove useful particularly in terms of extending the browser.
Setup
The JAR files required to use Lobo as an API may be found in the installation
directory of Lobo. Note that JAR files under the ext directory must
be present for many of the capabilities of the browser (including HTML) to work.
Extension JAR files are expected to be in a directory named ext, which is
a sibling of the Lobo executable JAR file.
In other words, lobo.jar, lobo-pub.jar and any other JAR
files in the main installation directory should be added to the CLASSPATH.
JAR files under the ext directory should not, as they are loaded
dynamically. But they are expected to retain their placement relative to
lobo.jar.
Size Note: JavaFX-related libraries (~ 10 Mb) are optional
if you are only interested in the HTML capability.
They are: javafxc.jar, javafxrt.jar and
Scenario-*.jar.
Getting Started
A required first step is to call
PlatformInit.getInstance().init
to initialize security, protocols, look & feel, the console, the default window factory and extensions.
If not all these features are required, at the very least
initProtocols
and
initExtensions
should be called.
The class FramePanel is a Swing
component that can be used like any other Swing component. It renders HTML, images, text files
and other content supported by browser extensions. To load a document in a FramePanel,
invoke navigate
or one of its variants.
Starting with Lobo 0.97.5, the class BrowserPanel
can be used to embed a browser frame that has an optional toolbar, address bar, status bar (including a progress
bar) and menu bar.
Examples
- FramePanel example.
The following is a barebones program (requiring Lobo 0.98+) that embeds
a FramePanel and loads the default Lobo home page.
LoboTestFrame.java
- BrowserPanel example with browser toolbar.
The following program (requiring Lobo 0.98+) embeds a
BrowserPanel instead. Hence, it has
a toolbar and a status bar.
BrowserPanelTest.java
The following is a screenshot of the BrowserPanelTest application GUI.
Licensing
Since Lobo, the application, is released under a GPL license, the Lobo browser API
is also GPL licensed.
Help
If you require community assistance, please visit
our Help Forum.
If you find something doesn't work quite the way it should, please submit a
bug report
or a
feature request.
See Also
Support The Project
|