JDIC API V2006 Release 0308

org.jdesktop.jdic.browser
Interface IWebBrowser

All Known Implementing Classes:
WebBrowser

public interface IWebBrowser

A IWebBrowser component represents a blank rectangular area of the screen onto which the application can display webpages or from which the application can trap events from the browser window. In order to show a Browser component in GUI, user need to add Browser to a top-level container, such as Frame.

The class that is interested in processing a Browser event should implement interface WebBrowserListener, and the object created with that class should use Browser's addWebBrowserListener method to register as a listener.

See Also:
IBrowserEngine, WebBrowserEvent, WebBrowserListener

Method Summary
 void addWebBrowserListener(WebBrowserListener listener)
          Adds a WebBrowserEvent listener.
 java.awt.Component asComponent()
          Returns the component to which the Browser paints.
 void back()
          Navigates to the previous session history item.
 void dispatchWebBrowserEvent(WebBrowserEvent event)
           
 java.lang.String executeScript(java.lang.String javaScript)
          Executes specified JavaScript code in a currently opened document.
 void forward()
          Navigates to the next session history item.
 IBrowserEngine getBrowserEngine()
          The BrowserEngine that was responsible for creating the browser instance.
 java.lang.String getContent()
          Returns the HTML content of a document, opened in a browser.
 java.lang.String getInitFailureMessage()
           
 int getInstanceNum()
          A IWebBrowser must have a ticket to identify itself, here is the instance num.For a IWebBrowser instance, a native browser instance will be created to deal with its requests, this instance num will be used get according native browser instance.
 int getNativeWindow()
          Get the windows' handler of native window
 java.net.URL getURL()
          Retrieves the URL that is currently being displayed.
 boolean isBackEnabled()
           
 boolean isForwardEnabled()
           
 boolean isInitialized()
           
 boolean isSynchronize()
          If the webbrowser works under synchronize model
 void refresh()
          Reloads the URL that is currently being displayed in the WebBrowser component.
 void removeWebBrowserListener(WebBrowserListener listener)
          Removes a WebBrowserEvent listener.
 void setContent(java.lang.String htmlContent)
          Sets new HTML content.
 void setInitFailureMessage(java.lang.String msg)
           
 void setInitialized(boolean b)
          Set if the IWebBrowser has been initialized.
 void setURL()
          Sets the document to be a blank page.
 void setURL(java.net.URL url)
          Navigates to a resource identified by an URL using HTTP GET method.
 void setURL(java.net.URL url, java.lang.String postData)
          Navigates to a resource identified by an URL using HTTP POST method.
 void setURL(java.net.URL url, java.lang.String postData, java.lang.String headers)
          HTTP headers to send to the server.
 void stop()
          Stops loading of the current URL.
 

Method Detail

addWebBrowserListener

public void addWebBrowserListener(WebBrowserListener listener)
Adds a WebBrowserEvent listener.

Parameters:
listener - object which implements WebBrowserListener interface.

removeWebBrowserListener

public void removeWebBrowserListener(WebBrowserListener listener)
Removes a WebBrowserEvent listener.

Parameters:
listener - object which implements WebBrowserListener interface. If the listener was not in the listeners list, then no listener will be removed.

isSynchronize

public boolean isSynchronize()
If the webbrowser works under synchronize model

Returns:

asComponent

public java.awt.Component asComponent()
Returns the component to which the Browser paints. This method is needed to add a Browser to

Returns:
The component on which the Browser paints.

getURL

public java.net.URL getURL()
Retrieves the URL that is currently being displayed.

Returns:
the current URL being display, or null if the WebBrowser object is not ready with initialization of itself.

setURL

public void setURL()
Sets the document to be a blank page.


setURL

public void setURL(java.net.URL url)
Navigates to a resource identified by an URL using HTTP GET method.

Parameters:
url - the URL to navigate.

setURL

public void setURL(java.net.URL url,
                   java.lang.String postData)
Navigates to a resource identified by an URL using HTTP POST method.

Parameters:
url - the URL to navigate.
postData - Data to send to the server during the HTTP POST transaction.

setURL

public void setURL(java.net.URL url,
                   java.lang.String postData,
                   java.lang.String headers)
HTTP headers to send to the server.

Parameters:
url - the URL to navigate to.
postData - the post data to send with the HTTP POST transaction. For example, "username=myid&password=mypasswd"
headers - the HTTP headers to send with the HTTP POST transaction.For ex,"content-type:text/html\r\ncontent-length:10"
Since:
0.9.2

getContent

public java.lang.String getContent()
Returns the HTML content of a document, opened in a browser.

Returns:
the HTML content of a document, opened in a browser.

setContent

public void setContent(java.lang.String htmlContent)
Sets new HTML content.

Parameters:
htmlContent - the HTML content to set.

executeScript

public java.lang.String executeScript(java.lang.String javaScript)
Executes specified JavaScript code in a currently opened document. This should not be called until after a documentComplete event is fired in WebBrowserListener.

Returns:
the result of JavaScript execution, if there is any.

back

public void back()
Navigates to the previous session history item.


forward

public void forward()
Navigates to the next session history item.


refresh

public void refresh()
Reloads the URL that is currently being displayed in the WebBrowser component.


stop

public void stop()
Stops loading of the current URL.


getBrowserEngine

public IBrowserEngine getBrowserEngine()
The BrowserEngine that was responsible for creating the browser instance. Use the BrowserEngine to get information about the Embedded Browser Component that is used for browsing.

Returns:
The BrowserEngine that was responsible for creating this browser instance.

isBackEnabled

public boolean isBackEnabled()

isForwardEnabled

public boolean isForwardEnabled()

isInitialized

public boolean isInitialized()

getInstanceNum

public int getInstanceNum()
A IWebBrowser must have a ticket to identify itself, here is the instance num.For a IWebBrowser instance, a native browser instance will be created to deal with its requests, this instance num will be used get according native browser instance.

Returns:

getNativeWindow

public int getNativeWindow()
Get the windows' handler of native window

Returns:

dispatchWebBrowserEvent

public void dispatchWebBrowserEvent(WebBrowserEvent event)
Parameters:
event -

setInitFailureMessage

public void setInitFailureMessage(java.lang.String msg)

getInitFailureMessage

public java.lang.String getInitFailureMessage()

setInitialized

public void setInitialized(boolean b)
Set if the IWebBrowser has been initialized.

Parameters:
b -

JDIC API V2006 Release 0308

For more information and documentation on JDIC, see JDIC website.

That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, working code examples, license terms and bug report information.

Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.