JWebPane Overview

Alexey Ushakov
Sun Microsystems
Where do we need it?

>   Email programs or IMs (viewing HTML)
>   Rich clients for content delivery systems
     (providi...
Project Goal

 Lightweight HTML component for Java and
  JavaFX providing:
  ●   Easy to use API
  ●   Modern HTML support...
Solutions
>   Create HTML renderer from scratch
     ●   Huge effort
     ●   Endless ongoing work to match modern HTML
> ...
Solutions: Mozilla, Webkit
>   Mozilla
     ●   Up-to-date
     ●   Opensource
     ●   Heavyweight

>   Webkit
     ●   U...
Webkit based Implementation
                                   User Application

>   WebKit engine for
     HTML parsing, ...
JWebPane plugins

>   Media Plugin
     ●   Embeds JavaFX Media Component
>   Java Plugin
     ●   Simple wrapper for Appl...
API: JWebPane

   UIDelegate

                   JWebPane            WebFrame

  PolicyDelegate


                   LoadS...
API: JWebPane
>   Provides basic web page browsing functionality
     and basic user interaction, such as navigating
     ...
API: JWebPane

JFrame f = new JFrame(“Browser”);

JWebPane browser = new JWebPane();

f.add(browser);

browser.load(someUR...
API: WebFrame
>   WebFrame is a nonvisual object that identifies an
    HTML <frame>, <iframe>, or <frameset>
    element
...
API: WebFrame


WebFrame wf = browser.getRootWebFrame();

for (WebFrame f : wf.getFrames()) {

    log.fine(f.getURL() + “...
API: PolicyDelegate
>   Single object associated with JWebPane for
     implementing a browser policy by allowing or
     ...
API. PolicyDelegate

class MyDelegate implements PolicyDelegate {

    public boolean permitAction(PolicyRequest r) {
    ...
API: UIDelegate
>   GUI object associated with a JWebPane and
     provides some basic UI for it.
>   Provides a set of GU...
API: UIDelegate

class MyUIDelegate extends DefaultUIDelegate {
   @Override
   public JWebPane createView(URL url) {
    ...
API: LoadStateListener
>   Listener for loading events such as:
     ●   loadingStarted
     ●   redirectProcessed
     ● ...
API. LoadStateListener
class MyListener implements LoadStateListener {
   public void loadingStarted(LoadStateEvent e) {
 ...
Deployment

>   JWebPane can be deployed as a JNLP extension
     ●   Plugins are deployed as separate JNLP
          exte...
Metrics (Windows XP)
                                      25


>   Download size                     20




         JWeb...
Questions?




             21
Alexey Ushakov
alexey.ushakov@sun.com
Upcoming SlideShare
Loading in …5
×

JWebPane presentation at JavaOne 2009

1,537 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,537
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

JWebPane presentation at JavaOne 2009

  1. 1. JWebPane Overview Alexey Ushakov Sun Microsystems
  2. 2. Where do we need it? > Email programs or IMs (viewing HTML) > Rich clients for content delivery systems (providing reviews for the content) > Arbitrary Java or JavaFX applications (adding advert banners) > Anywhere you can imagine! 2
  3. 3. Project Goal Lightweight HTML component for Java and JavaFX providing: ● Easy to use API ● Modern HTML support ● Java - JavaScript binding ● DOM access ● Plugins 3
  4. 4. Solutions > Create HTML renderer from scratch ● Huge effort ● Endless ongoing work to match modern HTML > Enhance Swing HTML support ● Significant work to get Swing up to date ● Need to keep it up to date > Use existing HTML rendering engine ● Mozilla ● Webkit 4
  5. 5. Solutions: Mozilla, Webkit > Mozilla ● Up-to-date ● Opensource ● Heavyweight > Webkit ● Up-to-date ● Opensource ● Lightweight 5
  6. 6. Webkit based Implementation User Application > WebKit engine for HTML parsing, CSS, JavaScript Java API HTML Component > Java for painting, metrics calculation, events handling, WebKit browser engine Plugins networking, unicode, input methods Java based Platform Abstraction Operating System 6
  7. 7. JWebPane plugins > Media Plugin ● Embeds JavaFX Media Component > Java Plugin ● Simple wrapper for Applet environment ● Same JVM > ActiveX Plugin ● Embeds IE Flash plugin 7
  8. 8. API: JWebPane UIDelegate JWebPane WebFrame PolicyDelegate LoadStateListener 8
  9. 9. API: JWebPane > Provides basic web page browsing functionality and basic user interaction, such as navigating links, and submitting HTML forms. ● Displays one web page at a time ● Handles scrolling internally (no need for JScrollPane) 9
  10. 10. API: JWebPane JFrame f = new JFrame(“Browser”); JWebPane browser = new JWebPane(); f.add(browser); browser.load(someURL); 10
  11. 11. API: WebFrame > WebFrame is a nonvisual object that identifies an HTML <frame>, <iframe>, or <frameset> element ● One WebFrame per HTML frame displayed in a JWebPane ● WebFrames have hierarchical structure ● Disposed after loading new pages 11
  12. 12. API: WebFrame WebFrame wf = browser.getRootWebFrame(); for (WebFrame f : wf.getFrames()) { log.fine(f.getURL() + “:” + f.getTitle()); } 12
  13. 13. API: PolicyDelegate > Single object associated with JWebPane for implementing a browser policy by allowing or rejecting sensitive operations such as: ● loading web pages ● opening new browser windows ● running scripts on pages 13
  14. 14. API. PolicyDelegate class MyDelegate implements PolicyDelegate { public boolean permitAction(PolicyRequest r) { return r.getType() != ENABLE_SCRIPTS; } } browser = new JWebPane(new MyDelegate(), ...); 14
  15. 15. API: UIDelegate > GUI object associated with a JWebPane and provides some basic UI for it. > Provides a set of GUI-related callbacks invoked by associated JWebPane to customize its appearance ● Displaying message/input boxes ● Creating new browser view for the given URL ● Setting status bar 15
  16. 16. API: UIDelegate class MyUIDelegate extends DefaultUIDelegate { @Override public JWebPane createView(URL url) { JWebPane view = new JWebPane(); view.load(url); return view; } } browser = new JWebPane(..., new MyUIDelegate()); 16
  17. 17. API: LoadStateListener > Listener for loading events such as: ● loadingStarted ● redirectProcessed ● loadingFinished or (if there is some problem) ● loadingRejected - PolicyDelegate rejects an operation ● loadingFailed - loading fails due to an error ● loadingStopped -loading is stopped with the JWebPane.stop() method 17
  18. 18. API. LoadStateListener class MyListener implements LoadStateListener { public void loadingStarted(LoadStateEvent e) { log.fine("Started:" + e.getURL()); } public void loadingFinished(LoadStateEvent e){ log.fine("Finished:" + e.getFrame().getTitle()); } public void loadingFailed(LoadStateEvent e) { log.severe("Failed:" + e.getError()); } } 18
  19. 19. Deployment > JWebPane can be deployed as a JNLP extension ● Plugins are deployed as separate JNLP extensions > Platforms Supported ● Windows ● Mac OS X ● Linux ● Solaris 19
  20. 20. Metrics (Windows XP) 25 > Download size 20 JWebPane: 2 mb 15 ● JWebPane Safari 10 Firefox ● Safari 3.1: 19.5 mb 5 ● Firefox 3: 7.1 mb 0 Download Size (mb) > Performance 35 (JWebPane/Safari/Firefox) 30 25 ● Bubblemark: 33/26/27 fps 20 JWebPane GUI Mark: 16/15/12 fps 15 Safari ● Firefox 10 ● SunSpider: 2.6/3.9/3.3 sec 5 0 GUIMark (fps) Bubblemark (fps) SunSpider (sec) 20
  21. 21. Questions? 21
  22. 22. Alexey Ushakov alexey.ushakov@sun.com

×