The Source for Java Technology Collaboration
User: Password:



Artem Ananiev

Artem Ananiev's Blog

Introducing JWebPane component

Posted by ixmal on May 29, 2008 at 02:26 AM | Comments (19)

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:


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • 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.

    Posted by: loubs001 on May 29, 2008 at 03:54 AM

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

    Posted by: liquid on May 29, 2008 at 05:57 AM

  • 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.

    Posted by: aberrant on May 29, 2008 at 10:31 AM

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

    Posted by: prunge on May 29, 2008 at 07:46 PM

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

    Posted by: nopjn on May 30, 2008 at 04:03 AM

  • 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

    Posted by: ixmal on May 30, 2008 at 04:23 AM

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

    Posted by: ixmal on May 30, 2008 at 04:25 AM

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

    Posted by: carcour on May 30, 2008 at 04:27 AM

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

    Posted by: fabriziogiudici on May 30, 2008 at 05:13 AM

  • 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)

    Posted by: ixmal on May 30, 2008 at 05:36 AM

  • 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.

    Posted by: carcour on May 30, 2008 at 08:22 AM


  • 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.

    Posted by: adamtaft on May 31, 2008 at 06:20 PM

  • 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).

    Posted by: neigor on June 01, 2008 at 01:07 AM

  • 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.

    Posted by: ixmal on June 02, 2008 at 03:09 AM

  • 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.

    Posted by: ixmal on June 02, 2008 at 03:14 AM

  • What license will the JWebPane be under?

    Posted by: tdugger on June 17, 2008 at 01:11 PM

  • 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?

    Posted by: scytacki on June 25, 2008 at 06:27 AM

  • 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!

    Posted by: io1 on July 13, 2008 at 02:15 AM

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

    Posted by: david_hoffer on August 04, 2008 at 07:46 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds