Skip to main content

Introducing JWebPane component

Posted by ixmal on May 29, 2008 at 2:26 AM PDT

Recently, at the JavaOne conference, Sun has introduced several new JavaFX related technologies and products. The Scene Graph and WebKit session was one of the technical sessions to present such advanced technologies:

Inside The JavaFXâ„¢ Script Technology-Based Runtime APIs: Scene Graph & JWebPane Component

This blog entry opens a series of articles about the technology described in the second part of the presentation - HTML component JWebPane. I'm set to explain what is it, when it could be employed in your application and when it couldn't be. :)

For many years, Java lacked a worthy component to render HTML content. HTML support in Swing was limited to the 3.2 version. Although the SwingLabs JDIC library provides a browsing component, it is hard to integrate into Swing applications because of its heavyweight implementation. The new component - JWebPane is not intended to substitute all known alternatives, however, it brings HTML support and easiness of use up to the high-level standard.

Those who attended the JavaOne session already know that JWebPane is based on the widely recognized open sourced engine - WebKit. It is not a secret any more. :) The WebKit architecture consists of two considerable parts. The first one is cross-platform, it is responsible for parsing documents, generating DOM, supporting JavaScript. Another part, platform-dependent, so called "port", is intended for communicating with network, rendering graphic content on the screen and other devices, event handling, and other features. JWebPane is a Java port, in which all cross-platform calls are implemented in Java.

Additionally, each port provides an API to develop browsing functionality using a particular library. For Java port, it is non surprisingly JavaFX. Moreover, JWebPane will became available in Swing applications. At the moment the API provides the following capabilities: adding the JWebPane component to the hierarchy of graphic components, documents loading control, handling the loading status events, navigation history support, and new windows control (both adding and removing). This API is supposed to be extended, if needed.

Finally, I'd like to demonstrate a small screen shot of the JWebPane application with new Nimbus Look and Feel available in JDK 6u10:

Next time I'll expose some technical details of the Java-port implementation and its interaction with WebKit.

Other blogs related to JWebPane:

Related Topics >>


Sorry for significant delays with my answers... We still work on the JWebPane component, but not as intensively as we'd like due to other tasks of higher priority. Unfortunately, I can't provide any exact information when it will be available for developers.

Is it available for download

Is it available for download to develop now?

I need Jwebpane

I need Jwebpane

See my comments to the next blog entry.

Hello, Any idea when it will become available? Thanks, Olivier

When/where can I get JWebPane? A beta version is fine as I just want to try some very basic usage.

Sounds exciting. So the layout is native WebKit, rendering is Java2D and the widgets are Swing components? I find that hard to believe, but i would LOVE to be proven wrong. Hopefully it will become part of OpenJDK, sounds like something I'd love to hack on.

Wow this looks really cool. When you say the cross platform part of WebKit is responsible for supporting JavaScript, does that mean it has a native javascript interpretor? I ask because 6.0 already has a version of the Rhino javascript interpretor. Some people might complain if there are 2 different implementations of javascript in the JDK.

will it be available with the javafx preview releases of june and luly ?

Artem will correct me if needed.

In my understanding JWebPane is Swing component, i.e. you can set any LAF you want.
Components inside web page (such as text field) are decorated in the same way as corresponding Swing components and using LAF defaults. However, they are not true Swing components and logic of interaction with them is provided by webkit. CSS should be applicable to the component as well to extent of it support by WebKit.
However, best approach is to test it. Could you post link to example with CSS you were thinking about and we will see how it look in JWebPane (vs Webkit/safari).

Yuck. That Nimbus Look and Feel sure does clash with the XP Olive theme. :(

Also, just curious about support for CSS?

It doesn't seem that JTextField (if it's used as the component for the <input type="text"> widget) would have enough configuration choices to be fully compliant to even moderate CSS spec without a lot of hacking.

So basically all textfields will be JTextFields with no context menu right? How about adding it. No other browser component have no context menu. Not having a context menu is not consistent.

What license will the JWebPane be under?

Hi Artem, we are eager to start evaluating the JWebPane but couldn’t get a hold of a trial version or figure out time-frame for its release.. Can you please provide more info regarding availability of product: When the component will be shipped, will it be part of Java FX, will it be packed separately. We are very excited about the new component and are ready to start POC… Any advice regarding how we may proceed would help!

How about browser plugins like Flash? For example, if JWebPane is embedded in a JScrollPane and there is a Flash component on the web page will it have the usual bad awt/swing behavior? How about embedding Applets inside of the page, is that supported? I'd hope it would be supported in a light weight way so a new JVM doesn't need to be started just for the applet. Can you describe why you chose WebKit over Gecko? Is it easier to implement the java2d rendering in WebKit instead of in Gecko?

To aberrant: WebKit is tightly integrated with its own JavaScript engine (written in C++ as well as the rest of WebKit code), so at the current moment we don't use Rhino from JDK6

It's amazing how you had the same idea then ! I guess going with WebKit instead of Gecko is a better thing.

So does anyone know anything about the presentation that was given about jwebpane yesterday? Is there a release of any sort? I'd hate to have to switch to SWT to get the components i want.

Yes, all the rendering is implemented with Java2D calls, and HTML form elements are painted using the corresponding Swing components (and have the same L&F as the embedding application)

Can you confirm loubs001's interpretation? That is, will really JWebPane delegate to Java2D the widgets?

When will it be available? Can't wait to try it

To liquid: I guess JWebPane will not be shipped with JavaFX in june, but I can't say it for sure

A proper HTML Swing component - something I've wanted for quite some time. Can't wait to play with it.

will native plugins be supported such as flash, microsoft-office viewers, PDF, applet etc.?

To adamtaft: you're right, having HTML forms components in a mixed environment of CSS and Swing L&F is somewhat tricky. At the current moment all the components look according to installed L&F with some respect to CSS like font family/size/color.

To carcour: all the context menus are handled by WebKit itself. Text components, for example, have standard Cut, Copy and Paste (and a couple more) items in the context menu.

Another possible feature may be to provide some API to add the items to the menus, however I'm not sure it can be easy done, and if developers really need this functionality.

No final decision about native (heavyweight) plugins is made yet. At the current moment we support lightweight ActiveX plugins on Windows platform