com.jniwrapper.win32.ie
Interface WebBrowser

All Superinterfaces:
ParentWindow
All Known Implementing Classes:
Browser, FrameBrowserSupport, HeadlessBrowser, IEAutomation

public interface WebBrowser
extends ParentWindow

The WebBrowser defines the base web browser interface and its various capabilities. This interface provides functionality that allows working with WebBrowser Control.

When you don't need to use the WebBrowser instance you should destroy it by invoking its close() method.

See Also:
- Java component that implements this interface and can be embedded in a Swing UI, - UI-less implementation of this interface, - an Automation-based browser component which you can use without embedding in a Swing UI

Nested Class Summary
static class WebBrowser.Properties
          Represents a set of event names that can be handled in the PropertyChangeListener listener.
 
Method Summary
 void addBrowserWindowListener(BrowserWindowListener listener)
          Adds window listener.
 void addDisposeListener(DisposeListener listener)
          Registers the listener for the current Browser instance that will receive events when the current Browser instance is disposed.
 void addNavigationListener(NavigationEventListener listener)
          Adds browser navigation event listener.
 void addNewWindowListener(NewWindowEventListener listener)
          Adds new window listener.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Adds a new property change listener.
 void addStatusListener(StatusEventListener listener)
          Adds browser status event listener.
 void close()
          Closes and disposes the current WebBrowser instance.
 void execute(BrowserCommand command)
          Executes the specified WebBrowser command.
 java.lang.Object executeScript(java.lang.String javaScript)
          Executes specified JavaScript code in a currently opened document.
 AuthenticationHandler getAuthenticationHandler()
          Returns the current browser authentication handler or null if it's was not specified.
 java.lang.Object getBrowserPeer()
          Returns an instance of the native WebBrowser peer as an instance of the IWebBrowser2 interface.
 java.lang.String getContent()
          Returns the string that represents HTML content of a currently loaded document in WebBrowser.
 java.lang.String getContent(boolean original)
          Returns the string that represents HTML content of a currently loaded document in WebBrowser.
 java.util.Set<Cookie> getCookies(java.lang.String url)
          Returns cookies, that are associated with the specified URL.
 java.util.Set<Cookie> getCookies(java.net.URL url)
          Returns cookies, that are associated with the specified URL.
 DialogEventHandler getDialogEventHandler()
          Returns the dialog events handler or null if it's was not specified.
 DisposeListener[] getDisposeListeners()
          Returns an array of all registered listeners for the current Browser instance.
 org.w3c.dom.html.HTMLDocument getDocument()
          Returns an instance of HTMLDocument that represents the HTML document currently loaded into the WebBrowser and provides access to the contents of the HTML Document Object Model (DOM).
 WebBrowserEventsHandler getEventHandler()
          Returns browser event handler.
 HttpSecurityHandler getHttpSecurityHandler()
          Returns http security handler that allows processing any security problems or null if it's not present.
 KeyFilter getKeyFilter()
          Returns key filter.
 java.lang.String getLocationURL()
          Returns the string that represents a URL of the resource that WebBrowser component is currently displayed.
 java.util.List getNavigationListeners()
          Returns browser navigation event listeners.
 NewWindowEventHandler getNewWindowHandler()
          Returns new window handler.
 java.util.List getNewWindowListeners()
          Returns new window listeners.
 com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
          Returns the OleMessageLoop thread in which executes all WebBrowser component operations.
 WebBrowser getParentBrowser()
          Returns the parent of the current WebBrowser instance or null if it hasn't parent.
 WebBrowser.Properties getProperties()
          Returns extended browser properties.
 ProxyConfiguration getProxy()
          Returns the proxy settings for the current WebBrowser control and all its children.
 ReadyState getReadyState()
          Returns the current ReadyState of the WebBrowser Control.
 ScriptErrorListener getScriptErrorListener()
          Returns script error listener for current page.
 java.util.List getStatusListeners()
          Returns browser status event listeners.
 int getZoomValue()
           
 void goBack()
          Navigates backward one item in the history list.
 void goForward()
          Navigates forward one item in the history list.
 void goHome()
          Navigates to the current home or start page.
 boolean isClosed()
          Returns true if the WebBrowser instance is closed and disposed.
 boolean isSilent()
          Return true if alert, confirmation and error dialogs are disabled else returns false.
 void navigate(java.lang.String location)
          Navigates to a resource identified by a URL or to a file identified by a full path.
 void navigate(java.lang.String location, java.lang.String postData)
          Navigates to a web resource specified by a HTTP URL with HTTP post data.
 void navigate(java.lang.String location, java.lang.String targetName, java.lang.String postData)
          Navigates to an entire web resource specified by a HTTP URL with HTTP post data into a specified window defined by targetName.
 void navigate(java.lang.String location, java.lang.String targetName, java.lang.String postData, java.lang.String headers)
          Navigates to an entire web resource specified by a HTTP URL with HTTP post data into a specified window defined by targetName.
 void refresh()
          Reloads the file that is currently displayed in the object.
 void removeBrowserWindowListener(BrowserWindowListener listener)
          Removes window listener.
 void removeDisposeListener(DisposeListener listener)
          Removes the listener so that it will not receive events when the current Browser instance is disposed.
 void removeNavigationListener(NavigationEventListener listener)
          Removes browser navigation event listener.
 void removeNewWindowListener(NewWindowEventListener listener)
          Removes new window listener.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Removes a specified property change listener.
 void removeStatusListener(StatusEventListener listener)
          Removes browser status event listener.
 void setAuthenticationHandler(AuthenticationHandler handler)
          Sets the specified browser authentication handler.
 void setContent(java.lang.String htmlContent)
          Sets the specified HTML content to the current WebBrowser document.
 void setCookie(java.lang.String url, Cookie cookie)
          Creates a new cookie for the specified URL using WinINet API.
 void setCookies(java.net.URL url, java.util.Set<Cookie> cookies)
          Creates a new cookies for the specified URL using WinINet API.
 void setDialogEventHandler(DialogEventHandler handler)
          Sets the listener interface for receiving show dialog events.
 void setEventHandler(WebBrowserEventsHandler handler)
          Sets browser event handler.
 void setHttpSecurityHandler(HttpSecurityHandler h)
          Sets the specified HTTP security handler that allows processing any security problems such as Invalid Certificate error, Invalid Certificate Name, Invalid Certificate Date, Moving from a non-SSL to an SSL connection because of a redirect or The redirection requires user confirmation problems.
 void setKeyFilter(KeyFilter keyFilter)
          Sets key filter.
 void setNewWindowHandler(NewWindowEventHandler newWindowHandler)
          Sets new window handler.
 void setParentBrowser(WebBrowser webBrowser)
          Sets the parent of the WebBrowser instance.
 void setProxy(ProxyConfiguration conf)
          Sets the specified proxy settings for the current WebBrowser control and all its children.
 void setScriptErrorListener(ScriptErrorListener listener)
          Setups javascript error listener for current page.
 void setSilent(boolean isSilent)
          Disables or enables alert, confirmation and error dialogs.
 void setZoomValue(int value)
           
 void stop()
          Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.
 void waitReady()
          Causes a current thread to wait for the completion of the current operation in the browser.
 void waitReady(long timeout)
          Causes a current thread to wait for the completion of a current operation in the browser for a specified amount of milliseconds.
 
Methods inherited from interface com.jniwrapper.win32.ie.ParentWindow
getRecentChild, trackChildren, waitChildCreation, waitChildCreation
 

Method Detail

navigate

void navigate(java.lang.String location)
Navigates to a resource identified by a URL or to a file identified by a full path. The WebBrowser can browse to any location in the local file system, on the network, or on the World Wide Web.

This method is executes asynchronously. To make sure that required resource is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Parameters:
location - the URL of the resource to display or the full path to the file location. The parameter cannot be null.
Throws:
java.lang.IllegalArgumentException - when location parameter is null.
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
navigate(String, String), navigate(String, String, String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

navigate

void navigate(java.lang.String location,
              java.lang.String postData)
Navigates to a web resource specified by a HTTP URL with HTTP post data. The WebBrowser can browse to any location in the local file system, on the network, or on the World Wide Web.

This method is executes asynchronously. To make sure that required resource is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Parameters:
location - the URL of the resource to display or the full path to the file location. The parameter cannot be null.
postData - HTTP post data (for example, "name=Alex&product=Pizza"), can be null.
Throws:
java.lang.IllegalArgumentException - when location parameter is null.
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
navigate(String), navigate(String, String, String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

navigate

void navigate(java.lang.String location,
              java.lang.String targetName,
              java.lang.String postData)
Navigates to an entire web resource specified by a HTTP URL with HTTP post data into a specified window defined by targetName.

This method is executes asynchronously. To make sure that required resource is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Parameters:
location - the URL of the resource to display or the full path to the file location. The parameter cannot be null.
targetName - The string that contains the name of the frame in which to display the resource. The possible values for this parameter are.
  • _blank - Load the link into a new unnamed window.
  • _parent - Load the link into the immediate parent of the document the link is in.
  • _self - Load the link into the same window the link was clicked in.
  • _top - Load the link into the full body of the current window.
  • WindowName - A named HTML frame. If no frame or window exists that matches the specified target name, a new window is opened for the specified link.
postData - HTTP post data (for example, "name=Alex&product=Pizza").
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
navigate(String), navigate(String, String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

navigate

void navigate(java.lang.String location,
              java.lang.String targetName,
              java.lang.String postData,
              java.lang.String headers)
Navigates to an entire web resource specified by a HTTP URL with HTTP post data into a specified window defined by targetName.

This method is executes asynchronously. To make sure that required resource is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Parameters:
location - the URL of the resource to display or the full path to the file location. The parameter cannot be null.
targetName - The string that contains the name of the frame in which to display the resource. The possible values for this parameter are.
  • _blank - Load the link into a new unnamed window.
  • _parent - Load the link into the immediate parent of the document the link is in.
  • _self - Load the link into the same window the link was clicked in.
  • _top - Load the link into the full body of the current window.
  • WindowName - A named HTML frame. If no frame or window exists that matches the specified target name, a new window is opened for the specified link.
postData - HTTP post data (for example, "name=Alex&product=Pizza").
headers - The string that contains additional HTTP headers to send to the server. These headers are added to the default Windows Internet Explorer headers. For example, headers can specify the action required of the server, the type of data being passed to the server, or a status code. This parameter is ignored if the URL is not an HTTP (or HTTPS) URL.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
navigate(String), navigate(String, String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getLocationURL

java.lang.String getLocationURL()
Returns the string that represents a URL of the resource that WebBrowser component is currently displayed.

If the resource is a folder or file on the network or local computer, the name is the full path of the folder or file in the Universal Naming Convention (UNC) format.

If this method is called before the first navigation is complete, the WebBrowser returns an empty string.

Returns:
location the string that represents a URL of a currently loaded resource
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getDocument

org.w3c.dom.html.HTMLDocument getDocument()
Returns an instance of HTMLDocument that represents the HTML document currently loaded into the WebBrowser and provides access to the contents of the HTML Document Object Model (DOM).

Before receiving an instance of HTMLDocument make sure that the entire document is loaded completely. For this you can use the NavigationEventListener.entireDocumentCompleted(WebBrowser, String) event.

Returns:
The HTML document currently loaded into the WebBrowser. This instance supports all the required properties and methods to access the entire contents of the active HTML document.
Throws:
java.lang.IllegalStateException - when WebBrowser.waitReady() method isn't called after last call of WebBrowser.navigate() or WebBrowser.setContent() methods; or when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
waitReady(), navigate(String), setContent(String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getParentBrowser

WebBrowser getParentBrowser()
Returns the parent of the current WebBrowser instance or null if it hasn't parent. If the WebBrowser control is in a frame, this method returns the WebBrowser instance of the main document that contains this frame. Otherwise, it delegates to the top-level WebBrowser control, if there is one.

Returns:
the parent of the browser or null if the browser hasn't parent.
See Also:
Browser.getParentBrowser(), HeadlessBrowser.getParentBrowser(), IEAutomation.getParentBrowser()

setParentBrowser

void setParentBrowser(WebBrowser webBrowser)
Sets the parent of the WebBrowser instance.

Parameters:
webBrowser - the parent of the browser.

goForward

void goForward()
Navigates forward one item in the history list.

During a browsing session, the WebBrowser control maintain a history list of all Web sites visited during a session. Use the StatusEventListener.forwardButtonEnabled event to check the enabled state of forward navigation.

To manage WebBrowser's history use the BrowserHistory class.

Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
goBack(), goHome(), BrowserHistory

goBack

void goBack()
Navigates backward one item in the history list.

During a browsing session, the WebBrowser control maintain a history list of all Web sites visited during a session. Use the StatusEventListener.backButtonEnabled event to check the enabled state of back navigation.

To manage WebBrowser's history use the BrowserHistory class.

Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
goForward(), goHome(), BrowserHistory

goHome

void goHome()
Navigates to the current home or start page.

The user can indicate the URL to use for the home page from the Internet Options dialog box, which is accessible from the Tools menu of Windows Internet Explorer, or in the Control Panel.

Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
goForward(), goBack()

stop

void stop()
Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.

Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
refresh(), navigate(String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

refresh

void refresh()
Reloads the file that is currently displayed in the object.

This method is the same as clicking the Refresh button or pressing F5 in Windows Internet Explorer.

To save time and network bandwidth, the WebBrowser control store pages from recently visited sites in cached memory on the user's hard disk. When you revisit a Web site, the page is reloaded from the local disk instead of being downloaded again from the server. To ensure that you are viewing the most current version of the page, you can force a fresh download by using this method. This method adds the "Pragma: No-cache" HTTP header to the request.

Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.

execute

void execute(BrowserCommand command)
Executes the specified WebBrowser command. Each WebBrowser command must inherit the BrowserCommand abstract class.

For example, to print currently loaded web page, the following command should be executed:

 WebBrowser browser = new HeadlessBrowser();
 browser.execute(new PrintCommand());

Parameters:
command - the specified WebBrowser command.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
PrintCommand, PrintPreviewCommand, SaveAsCommand

setContent

void setContent(java.lang.String htmlContent)
Sets the specified HTML content to the current WebBrowser document.

This method is executes asynchronously. To make sure that the new HTML content was applied to the document completely, use the NavigationEventListener.entireDocumentCompleted event. It may be necessary when the document contains some resources (such as images or JavaScript files) that require some time to download.

Parameters:
htmlContent - a string that represents HTML content to set to the current document.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
navigate(String), navigate(String, String), navigate(String, String, String), getContent(), getContent(boolean), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getContent

java.lang.String getContent()
Returns the string that represents HTML content of a currently loaded document in WebBrowser. To make sure that the document is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Note: the outerHTML propertry of the document HTML element is used in this method. So, it always returns the actual HTML of the document. To get the HTML that was downloaded from the server use the getContent(true) method.

Returns:
the string that contains a combination of text and tags.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
setContent(String), getContent(boolean), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getContent

java.lang.String getContent(boolean original)
Returns the string that represents HTML content of a currently loaded document in WebBrowser. To make sure that the document is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Parameters:
original - if true then returns the original HTML content (like View Source command in context menu of Internet Explorer browser), otherwise this method returns the actual content of a document according to its DOM.
Returns:
the HTML content of a document, opened in a browser.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
getContent(), setContent(String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

executeScript

java.lang.Object executeScript(java.lang.String javaScript)
Executes specified JavaScript code in a currently opened document.

Script executed through the IHTMLWindow2.execScript method can access all global variables available to the calling script.

Parameters:
javaScript - the string that specifies the code to be executed.
Returns:
the result of JavaScript execution, if any (String, or COM object).
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.

getReadyState

ReadyState getReadyState()
Returns the current ReadyState of the WebBrowser Control.

Returns:
the current state of the WebBrowser Control.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.

addPropertyChangeListener

void addPropertyChangeListener(java.lang.String propertyName,
                               java.beans.PropertyChangeListener listener)
Adds a new property change listener. The available property names are presented in the WebBrowser.Properties class.

Parameters:
propertyName - property name.
listener - listener instance.

removePropertyChangeListener

void removePropertyChangeListener(java.lang.String propertyName,
                                  java.beans.PropertyChangeListener listener)
Removes a specified property change listener. The available property names are presented in the WebBrowser.Properties class.

Parameters:
propertyName - property name.
listener - listener instance.

waitReady

void waitReady()
Causes a current thread to wait for the completion of the current operation in the browser.

Important: successful call of this method guaranties that you can get DOM document of loaded page. Please see typical usage of this method in the code below:

     // navigate to Google page
     browser.navigate("google.com");
 

// wait until page completely loaded browser.waitReady();

// DOM document is available Document document = browser.getDocument();

If you miss WebBrowser.waitReady() call after navigation call then IllegalStateException is thrown in WebBrowser.getDocument() call.

Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
navigate(String), setContent(String), getDocument()

waitReady

void waitReady(long timeout)
Causes a current thread to wait for the completion of a current operation in the browser for a specified amount of milliseconds.

Parameters:
timeout - the number of milliseconds to wait.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.

getBrowserPeer

java.lang.Object getBrowserPeer()
Returns an instance of the native WebBrowser peer as an instance of the IWebBrowser2 interface. The returned value can be casted to IWebBrowser2 interface.

Returns:
an instance of the native WebBrowser peer.
Throws:
java.lang.IllegalStateException - when the passed browser does not have a native peer or WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.

addNavigationListener

void addNavigationListener(NavigationEventListener listener)
Adds browser navigation event listener.

Parameters:
listener - browser event listener.

removeNavigationListener

void removeNavigationListener(NavigationEventListener listener)
Removes browser navigation event listener.

Parameters:
listener - browser event listener.

getNavigationListeners

java.util.List getNavigationListeners()
Returns browser navigation event listeners.

Returns:
list of browser event listeners

addStatusListener

void addStatusListener(StatusEventListener listener)
Adds browser status event listener.

Parameters:
listener - browser event listener.

removeStatusListener

void removeStatusListener(StatusEventListener listener)
Removes browser status event listener.

Parameters:
listener - browser event listener.

getStatusListeners

java.util.List getStatusListeners()
Returns browser status event listeners.

Returns:
list of browser event listeners

setEventHandler

void setEventHandler(WebBrowserEventsHandler handler)
Sets browser event handler.

Parameters:
handler - event handler

getEventHandler

WebBrowserEventsHandler getEventHandler()
Returns browser event handler.

Returns:
browser event handler

setAuthenticationHandler

void setAuthenticationHandler(AuthenticationHandler handler)
Sets the specified browser authentication handler. The authentication handler allows handling the authenticate events from the browser object. Currently supported the basic, digest and NTLM authentication schemes.

Parameters:
handler - the authentication handler
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
getAuthenticationHandler()

getAuthenticationHandler

AuthenticationHandler getAuthenticationHandler()
Returns the current browser authentication handler or null if it's was not specified. The authentication handler allows handling the authenticate events from the browser object. Currently supported the basic, digest and NTLM authentication schemes.

By default this method always returns null.

Returns:
the current browser authentication handler or null.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
setAuthenticationHandler(AuthenticationHandler)

setDialogEventHandler

void setDialogEventHandler(DialogEventHandler handler)
Sets the listener interface for receiving show dialog events. This method allows specifying the handler for processing events when the JavaScript Alert, Confirmation or Error dialog should be shown.

By default the WebBrowser component has its own implementation of the DialogEventHandler. Please see the Browser.setDialogEventHandler(com.jniwrapper.win32.ie.event.DialogEventHandler) and HeadlessBrowser.setDialogEventHandler(com.jniwrapper.win32.ie.event.DialogEventHandler) method.

Parameters:
handler - dialog event handler
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
getDialogEventHandler(), setSilent(boolean), isSilent(), Browser.setDialogEventHandler(com.jniwrapper.win32.ie.event.DialogEventHandler), HeadlessBrowser.setDialogEventHandler(com.jniwrapper.win32.ie.event.DialogEventHandler)

getDialogEventHandler

DialogEventHandler getDialogEventHandler()
Returns the dialog events handler or null if it's was not specified.

By default this method returns the default implementation of the DialogEventHandler which is different for each implementation of the WebBrowser interface. Please see the Browser.getDialogEventHandler() and HeadlessBrowser.getDialogEventHandler() method.

Returns:
the dialog events handler or null if it's was not specified.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
setDialogEventHandler(DialogEventHandler), setSilent(boolean), isSilent(), Browser.getDialogEventHandler(), HeadlessBrowser.getDialogEventHandler()

setScriptErrorListener

void setScriptErrorListener(ScriptErrorListener listener)
Setups javascript error listener for current page.

Parameters:
listener - javascript error listener

getScriptErrorListener

ScriptErrorListener getScriptErrorListener()
Returns script error listener for current page.

Returns:
script error listener

close

void close()
Closes and disposes the current WebBrowser instance. After invoking this method every access to the closed WebBrowser instance will cause the IllegalStateException error. Use this method when you don't need the WebBrowser instance anymore.

You should invoke this method to destroy all not daemon threads which are Browser instance is used. If you do not invoke this method, then your Java application will not exit as expected - without invoking System.exit(0) method.

See Also:
isClosed()

isClosed

boolean isClosed()
Returns true if the WebBrowser instance is closed and disposed. Use this method when you need to make sure that the WebBrowser instance is alive and you can invoke its methods.

Returns:
true if the WebBrowser instance is closed and disposed.
See Also:
close()

setSilent

void setSilent(boolean isSilent)
Disables or enables alert, confirmation and error dialogs.

This method call modifies dialog event handler through setDialogEventHandler() call.

Parameters:
isSilent - if true then enter to silent mode else leave silent mode.

isSilent

boolean isSilent()
Return true if alert, confirmation and error dialogs are disabled else returns false.

Returns:
true if in silent mode else returns false.

setCookie

void setCookie(java.lang.String url,
               Cookie cookie)
Creates a new cookie for the specified URL using WinINet API. This is an analogue of the InternetSetCookie native function.

Parameters:
url - specifies an URL, a new cookie will be associated with.
cookie - specifies a new cookie.

getCookies

java.util.Set<Cookie> getCookies(java.lang.String url)
Returns cookies, that are associated with the specified URL. This is an analogue of the InternetGetCookie native function.

Parameters:
url - specifies an URL.
Returns:
cookies, that are associated with the specified URL.

setNewWindowHandler

void setNewWindowHandler(NewWindowEventHandler newWindowHandler)
Sets new window handler.

Parameters:
newWindowHandler - new window handler

getNewWindowHandler

NewWindowEventHandler getNewWindowHandler()
Returns new window handler.

Returns:
new window handler

addNewWindowListener

void addNewWindowListener(NewWindowEventListener listener)
Adds new window listener.

Parameters:
listener - new window listener

removeNewWindowListener

void removeNewWindowListener(NewWindowEventListener listener)
Removes new window listener.

Parameters:
listener - new window listener

getNewWindowListeners

java.util.List getNewWindowListeners()
Returns new window listeners.

Returns:
new window listeners

setKeyFilter

void setKeyFilter(KeyFilter keyFilter)
Sets key filter.

Parameters:
keyFilter - key filter

getKeyFilter

KeyFilter getKeyFilter()
Returns key filter.

Returns:
key filter

getProperties

WebBrowser.Properties getProperties()
Returns extended browser properties.

Returns:
extended browser properties.

addBrowserWindowListener

void addBrowserWindowListener(BrowserWindowListener listener)
Adds window listener.

Parameters:
listener - the window listener

removeBrowserWindowListener

void removeBrowserWindowListener(BrowserWindowListener listener)
Removes window listener.

Parameters:
listener - the window listener

getOleMessageLoop

com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
Returns the OleMessageLoop thread in which executes all WebBrowser component operations. Each WebBrowser instance with its children run in its own OleMessageLoop thread.

Returns:
the OleMessageLoop thread.

setProxy

void setProxy(ProxyConfiguration conf)
Sets the specified proxy settings for the current WebBrowser control and all its children. These settings will be applied only for the current WebBrowser instance and they will not affect on the system local area network (LAN) proxy settings.

In order to change the system local area network (LAN) proxy settings please use the Browsers.setProxy(ProxyConfiguration) method.

Parameters:
conf - the proxy settings. This parameter cannot be null.
Throws:
java.lang.IllegalStateException - when the passed browser does not have a native peer or WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
getProxy(), Browsers.setProxy(ProxyConfiguration)

getProxy

ProxyConfiguration getProxy()
Returns the proxy settings for the current WebBrowser control and all its children. In order to receive the global system local area network (LAN) proxy settings please use the Browsers.getProxy() method.

Returns:
the proxy settings for the current WebBrowser control.
Throws:
java.lang.IllegalStateException - when the passed browser does not have a native peer or WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
setProxy(ProxyConfiguration), Browsers.getProxy()

getCookies

java.util.Set<Cookie> getCookies(java.net.URL url)
Returns cookies, that are associated with the specified URL.

It checks in the windows\cookies directory for persistent cookies that have an expiration date set sometime in the future.

It also searches memory for any session cookies, that is, cookies that do not have an expiration date that were created in the same process by CookieManager.setCookie(), because these cookies are not written to any files. Rules for creating cookie files are internal to the system and can change in the future.

Note: The method does not return cookies that the server marked as non-scriptable with the "HttpOnly" attribute in the Set-Cookie header.

Parameters:
url - specifies an URL.
Returns:
cookies, that are associated with the specified URL.

setCookies

void setCookies(java.net.URL url,
                java.util.Set<Cookie> cookies)
Creates a new cookies for the specified URL using WinINet API.

Cookies created by this method without an expiration date are stored in memory and are available only in the same process that created them. Cookies that include an expiration date are stored in the windows\cookies directory.

Parameters:
url - specifies an URL, a new cookie will be associated with.
cookies - the collection of Cookie objects.

setHttpSecurityHandler

void setHttpSecurityHandler(HttpSecurityHandler h)
Sets the specified HTTP security handler that allows processing any security problems such as Invalid Certificate error, Invalid Certificate Name, Invalid Certificate Date, Moving from a non-SSL to an SSL connection because of a redirect or The redirection requires user confirmation problems.

Parameters:
h - the specified HTTP security handler.
Throws:
java.lang.IllegalStateException - when the passed browser does not have a native peer or WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
getHttpSecurityHandler()

getHttpSecurityHandler

HttpSecurityHandler getHttpSecurityHandler()
Returns http security handler that allows processing any security problems or null if it's not present. By default this method always returns null and all security problems are processing by default Internet Explorer security handler.

Returns:
the current http security handler that allows processing any security problems or null if it's not present
Throws:
java.lang.IllegalStateException - when the passed browser does not have a native peer or WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
setHttpSecurityHandler(com.jniwrapper.win32.ie.event.HttpSecurityHandler)

addDisposeListener

void addDisposeListener(DisposeListener listener)
Registers the listener for the current Browser instance that will receive events when the current Browser instance is disposed.

Parameters:
listener - the listener to receive browser dispose events.

removeDisposeListener

void removeDisposeListener(DisposeListener listener)
Removes the listener so that it will not receive events when the current Browser instance is disposed.

Parameters:
listener - the listener to remove.

getDisposeListeners

DisposeListener[] getDisposeListeners()
Returns an array of all registered listeners for the current Browser instance.

Returns:
an array of all registered listeners for the current Browser instance.

getZoomValue

int getZoomValue()

setZoomValue

void setZoomValue(int value)