com.jniwrapper.win32.ie
Class Browser

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.jniwrapper.win32.ie.Browser
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, ParentWindow, java.io.Serializable, WebBrowser

public class Browser
extends javax.swing.JComponent
implements WebBrowser

This component implements the WebBrowser interface and provides various capabilities for a Java application, such as Web surfing, documents viewing, etc.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Nested classes inherited from class com.jniwrapper.win32.ie.WebBrowser
WebBrowser.Properties
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Browser()
          Creates WebBrowser component.
Browser(Browser parent)
          Creates child browser component.
 
Method Summary
 void addBrowserWindowListener(BrowserWindowListener listener)
          Adds window listener.
 void addNavigationListener(NavigationEventListener listener)
          Adds browser navigation event listener.
 void addNewWindowListener(NewWindowEventListener listener)
          Adds new window listener.
 void addNotify()
           
 void addStatusListener(StatusEventListener listener)
          Adds browser status event listener.
 void close()
          Closes and disposes the current WebBrowser instance.
 void execute(BrowserCommand command)
          Executes specified 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 web browser peer.
 java.lang.String getContent()
          Returns the HTML content of a document, opened in a browser.
 java.lang.String getContent(boolean original)
          Returns the string that represents HTML content of a currently loaded document in WebBrowser.
 org.w3c.dom.Element getContextElement()
          Returns element on which the context menu was invoked last time.
 ContextMenuProvider getContextMenuProvider()
          Returns the context menu provider for the browser.
 java.util.Set getCookies(java.lang.String url)
          Deprecated. Use the CookieManager.getCookies(URL url) method instead.
 DialogEventHandler getDialogEventHandler()
          Returns the dialog events handler or null if it's was not specified.
 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.
 HtmlDialogListener getHtmlDialogListener()
          Returns the current HTML Dialog listener or if it's not registered.
 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.awt.Dimension getMinimumSize()
           
 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()
          Return browser OLE message loop.
 WebBrowser getParentBrowser()
          Returns the parent browser of the current instance.
 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 browser.
 WebBrowser getRecentChild()
          Returns recent created child object since last trackChildren() method call.
 java.awt.Image getScreenShot(boolean wholePage)
          Returns an image that represent screen shot of the page.
 ScriptErrorListener getScriptErrorListener()
          Returns script error listener for current page.
 java.util.List getStatusListeners()
          Returns browser status event listeners.
 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 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 refresh()
          Reloads the file that is currently displayed in the object.
 void removeBrowserWindowListener(BrowserWindowListener listener)
          Removes window listener.
 void removeNavigationListener(NavigationEventListener listener)
          Removes browser navigation event listener.
 void removeNewWindowListener(NewWindowEventListener listener)
          Removes new window listener.
 void removeNotify()
           
 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)
          Set new HTML content.
 void setContextMenuProvider(ContextMenuProvider contextMenuProvider)
          Sets the context menu provider for the browser.
 void setCookie(java.lang.String url, Cookie cookie)
          Deprecated. Use the CookieManager.setCookie(URL url, Cookie cookie) or CookieManager.setCookies(URL url, Set cookies) methods instead.
 void setDialogEventHandler(DialogEventHandler handler)
          Sets the listener interface for receiving show dialog events.
 void setEnabled(boolean enabled)
          Sets whether or not this component is enabled.
 void setEventHandler(WebBrowserEventsHandler handler)
          Sets browser event handler.
 void setHtmlDialogListener(HtmlDialogListener listener)
          Sets the specified HTML Dialog listener that allows receiving event when the HTML Dialog is shown and its document is loaded completely.
 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 browser)
          Deprecated. Will be removed because WebBrowser instance will receive parent automatically.
 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 stop()
          Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.
 void trackChildren()
          Starts to collect information about child object creation.
 WebBrowser waitChildCreation()
          Blocks execution until child is created since last trackChildren() call and returns this child.
 WebBrowser waitChildCreation(java.lang.Runnable operationThatCreatesChild)
          Executes operation specified in the parameter and returns when child created by the operation is opened.
 void waitReady()
          Deprecated. Use the NavigationEventListener.entireDocumentCompleted event to make sure that the document is loaded completely.
 void waitReady(long timeout)
          Deprecated. Use the NavigationEventListener.entireDocumentCompleted event to make sure that the document is loaded completely.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jniwrapper.win32.ie.WebBrowser
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

Browser

public Browser()
Creates WebBrowser component.


Browser

public Browser(Browser parent)
Creates child browser component.

Parameters:
parent - the parent for the child browser.
Method Detail

addNotify

public void addNotify()

removeNotify

public void removeNotify()

getMinimumSize

public java.awt.Dimension getMinimumSize()

getParentBrowser

public WebBrowser getParentBrowser()
Returns the parent browser of the current instance.

Specified by:
getParentBrowser in interface WebBrowser
Returns:
the parent of the browser or null if the browser has no parent.
See Also:
getParentBrowser(), HeadlessBrowser.getParentBrowser(), IEAutomation.getParentBrowser()

setParentBrowser

public void setParentBrowser(WebBrowser browser)
Deprecated. Will be removed because WebBrowser instance will receive parent automatically.

Sets the parent browser for the current instance.

Specified by:
setParentBrowser in interface WebBrowser
Parameters:
browser - the parent browser.

executeScript

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

Specified by:
executeScript in interface WebBrowser
Parameters:
javaScript - JavaScript to execute.
Returns:
the result of JavaScript execution, if any.

navigate

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

Specified by:
navigate in interface WebBrowser
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

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

Specified by:
navigate in interface WebBrowser
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

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

Specified by:
navigate in interface WebBrowser
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)

getLocationURL

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

Specified by:
getLocationURL in interface WebBrowser
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)

goForward

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

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

goBack

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

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

goHome

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

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

refresh

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

Specified by:
refresh in interface WebBrowser

stop

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

Specified by:
stop in interface WebBrowser
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)

execute

public void execute(BrowserCommand command)
Executes specified command.

Specified by:
execute in interface WebBrowser
Parameters:
command - browser command.
See Also:
PrintCommand, PrintPreviewCommand, SaveAsCommand

getDocument

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

Specified by:
getDocument in interface WebBrowser
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:
HTMLDocument, WebBrowser.waitReady(), WebBrowser.navigate(String), WebBrowser.setContent(String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

setContent

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

Specified by:
setContent in interface WebBrowser
Parameters:
htmlContent - HTML content to set.
See Also:
WebBrowser.navigate(String), WebBrowser.navigate(String, String), WebBrowser.navigate(String, String, String), WebBrowser.getContent(), WebBrowser.getContent(boolean), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getContent

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

Specified by:
getContent in interface WebBrowser
Returns:
the HTML content of a document, opened in a browser.
See Also:
WebBrowser.setContent(String), WebBrowser.getContent(boolean), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getContent

public java.lang.String getContent(boolean original)
Description copied from interface: WebBrowser
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.

Specified by:
getContent in interface WebBrowser
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.
See Also:
WebBrowser.getContent(), WebBrowser.setContent(String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

setContextMenuProvider

public void setContextMenuProvider(ContextMenuProvider contextMenuProvider)
Sets the context menu provider for the browser.

If context menu provider for the browser is null then show default context menu. If the provider isn't null then show custom menu or don't show any menu (depends from ContextMenuProvider implementation).

Parameters:
contextMenuProvider - context menu provider instance or null.

getContextMenuProvider

public ContextMenuProvider getContextMenuProvider()
Returns the context menu provider for the browser.

If context menu provider for the browser is null then show default context menu. If the provider isn't null then show custom menu or don't show any menu (depends from ContextMenuProvider implementation).

Returns:
context menu provider instance or null.

getReadyState

public ReadyState getReadyState()
Returns the current ReadyState of the browser.

Specified by:
getReadyState in interface WebBrowser
Returns:
the current state of the browser.

getBrowserPeer

public java.lang.Object getBrowserPeer()
Returns an instance of the native web browser peer.

Specified by:
getBrowserPeer in interface WebBrowser
Returns:
native peer object.
Throws:
java.lang.IllegalStateException - if the passed browser does not have a native peer.

waitReady

public void waitReady()
Deprecated. Use the NavigationEventListener.entireDocumentCompleted event to make sure that the document is loaded completely.

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.

Specified by:
waitReady in interface WebBrowser
See Also:
WebBrowser.navigate(String), WebBrowser.setContent(String), WebBrowser.getDocument()

waitReady

public void waitReady(long timeout)
Deprecated. Use the NavigationEventListener.entireDocumentCompleted event to make sure that the document is loaded completely.

Causes a current thread to wait for the completion of a current operation in the browser for a specified amount of milliseconds.

Specified by:
waitReady in interface WebBrowser
Parameters:
timeout - the number of milliseconds to wait.

getContextElement

public org.w3c.dom.Element getContextElement()
Returns element on which the context menu was invoked last time.

Returns:
context element object.

addNavigationListener

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

Specified by:
addNavigationListener in interface WebBrowser
Parameters:
listener - browser event listener.

removeNavigationListener

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

Specified by:
removeNavigationListener in interface WebBrowser
Parameters:
listener - browser event listener.

getNavigationListeners

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

Specified by:
getNavigationListeners in interface WebBrowser
Returns:
list of browser event listeners

addStatusListener

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

Specified by:
addStatusListener in interface WebBrowser
Parameters:
listener - browser event listener.

getStatusListeners

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

Specified by:
getStatusListeners in interface WebBrowser
Returns:
list of browser event listeners

removeStatusListener

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

Specified by:
removeStatusListener in interface WebBrowser
Parameters:
listener - browser event listener.

setAuthenticationHandler

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

Specified by:
setAuthenticationHandler in interface WebBrowser
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

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

Specified by:
getAuthenticationHandler in interface WebBrowser
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)

getEventHandler

public WebBrowserEventsHandler getEventHandler()
Returns browser event handler.

Specified by:
getEventHandler in interface WebBrowser
Returns:
browser event handler

setEventHandler

public void setEventHandler(WebBrowserEventsHandler handler)
Sets browser event handler.

Specified by:
setEventHandler in interface WebBrowser
Parameters:
handler - event handler

setScriptErrorListener

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

Specified by:
setScriptErrorListener in interface WebBrowser
Parameters:
listener - javascript error listener

getScriptErrorListener

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

Specified by:
getScriptErrorListener in interface WebBrowser
Returns:
script error listener

close

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

Specified by:
close in interface WebBrowser
See Also:
isClosed()

isClosed

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

Specified by:
isClosed in interface WebBrowser
Returns:
if the WebBrowser instance is closed and disposed.
See Also:
close()

setSilent

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

Specified by:
setSilent in interface WebBrowser
Parameters:
isSilent - if true then enter to silent mode else leave silent mode.

isSilent

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

Specified by:
isSilent in interface WebBrowser
Returns:
true if in silent mode else returns false.

getOleMessageLoop

public com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
Return browser OLE message loop.

Specified by:
getOleMessageLoop in interface WebBrowser
Returns:
browser OLE message loop.

setProxy

public void setProxy(ProxyConfiguration conf)
Description copied from interface: WebBrowser
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.

Specified by:
setProxy in interface WebBrowser
Parameters:
conf - the proxy settings. This parameter cannot be null.
See Also:
WebBrowser.getProxy(), Browsers.setProxy(ProxyConfiguration)

getProxy

public ProxyConfiguration getProxy()
Description copied from interface: WebBrowser
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.

Specified by:
getProxy in interface WebBrowser
Returns:
the proxy settings for the current WebBrowser control.
See Also:
WebBrowser.setProxy(ProxyConfiguration), Browsers.getProxy()

setHttpSecurityHandler

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

Specified by:
setHttpSecurityHandler in interface WebBrowser
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

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

Specified by:
getHttpSecurityHandler in interface WebBrowser
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)

setHtmlDialogListener

public void setHtmlDialogListener(HtmlDialogListener listener)
Sets the specified HTML Dialog listener that allows receiving event when the HTML Dialog is shown and its document is loaded completely. The HTML Dialog can be opened using the and JavaScript functions.

Parameters:
listener - the specified HTML Dialog listener.
See Also:
getHtmlDialogListener()

getHtmlDialogListener

public HtmlDialogListener getHtmlDialogListener()
Returns the current HTML Dialog listener or if it's not registered.

Returns:
the current HTML Dialog listener or if it's not registered.
See Also:
setHtmlDialogListener(com.jniwrapper.win32.ie.event.HtmlDialogListener)

setDialogEventHandler

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

Specified by:
setDialogEventHandler in interface WebBrowser
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()

getDialogEventHandler

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

By default this method returns the BrowserDialogEventHandler implementation.

Specified by:
getDialogEventHandler in interface WebBrowser
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()

setNewWindowHandler

public void setNewWindowHandler(NewWindowEventHandler newWindowHandler)
Sets new window handler.

Specified by:
setNewWindowHandler in interface WebBrowser
Parameters:
newWindowHandler - new window handler

getNewWindowHandler

public NewWindowEventHandler getNewWindowHandler()
Returns new window handler.

Specified by:
getNewWindowHandler in interface WebBrowser
Returns:
new window handler

addNewWindowListener

public void addNewWindowListener(NewWindowEventListener listener)
Adds new window listener.

Specified by:
addNewWindowListener in interface WebBrowser
Parameters:
listener - new window listener

removeNewWindowListener

public void removeNewWindowListener(NewWindowEventListener listener)
Removes new window listener.

Specified by:
removeNewWindowListener in interface WebBrowser
Parameters:
listener - new window listener

getNewWindowListeners

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

Specified by:
getNewWindowListeners in interface WebBrowser
Returns:
new window listeners

trackChildren

public void trackChildren()
Starts to collect information about child object creation.

Specified by:
trackChildren in interface ParentWindow

getRecentChild

public WebBrowser getRecentChild()
Returns recent created child object since last trackChildren() method call.

Specified by:
getRecentChild in interface ParentWindow
Returns:
recent opened child window after the last trackChildren() method call. If there isn't opened windows after this call then returns null.

waitChildCreation

public WebBrowser waitChildCreation()
Blocks execution until child is created since last trackChildren() call and returns this child.

In other words, this method waits until getRecentChild() call returns non-null object.

Specified by:
waitChildCreation in interface ParentWindow
Returns:
recent created child

waitChildCreation

public WebBrowser waitChildCreation(java.lang.Runnable operationThatCreatesChild)
Executes operation specified in the parameter and returns when child created by the operation is opened.

Specified by:
waitChildCreation in interface ParentWindow
Parameters:
operationThatCreatesChild - operation
Returns:
child created by the operation

setCookie

public void setCookie(java.lang.String url,
                      Cookie cookie)
Deprecated. Use the CookieManager.setCookie(URL url, Cookie cookie) or CookieManager.setCookies(URL url, Set cookies) methods instead.

Creates a new cookie for the specified URL using WinINet API. This is an analogue of the InternetSetCookie native function.

Specified by:
setCookie in interface WebBrowser
Parameters:
url - specifies an URL, a new cookie will be associated with.
cookie - specifies a new cookie.

getCookies

public java.util.Set getCookies(java.lang.String url)
Deprecated. Use the CookieManager.getCookies(URL url) method instead.

Returns cookies, that are associated with the specified URL. This is an analogue of the InternetGetCookie native function.

Specified by:
getCookies in interface WebBrowser
Parameters:
url - specifies an URL.
Returns:
cookies, that are associated with the specified URL.

setKeyFilter

public void setKeyFilter(KeyFilter keyFilter)
Sets key filter.

Specified by:
setKeyFilter in interface WebBrowser
Parameters:
keyFilter - key filter

getKeyFilter

public KeyFilter getKeyFilter()
Returns key filter.

Specified by:
getKeyFilter in interface WebBrowser
Returns:
key filter

getScreenShot

public java.awt.Image getScreenShot(boolean wholePage)
Returns an image that represent screen shot of the page.

Parameters:
wholePage - if true returns the whole page not just what is visible
Returns:
an image that represent screen shot of the page

getProperties

public WebBrowser.Properties getProperties()
Returns extended browser properties.

Specified by:
getProperties in interface WebBrowser
Returns:
extended browser properties.

addBrowserWindowListener

public void addBrowserWindowListener(BrowserWindowListener listener)
Adds window listener.

Specified by:
addBrowserWindowListener in interface WebBrowser
Parameters:
listener - the window listener

removeBrowserWindowListener

public void removeBrowserWindowListener(BrowserWindowListener listener)
Removes window listener.

Specified by:
removeBrowserWindowListener in interface WebBrowser
Parameters:
listener - the window listener

setEnabled

public void setEnabled(boolean enabled)
Sets whether or not this component is enabled. A component that is enabled may respond to user input, while a component that is not enabled cannot respond to user input.

Parameters:
enabled - true if this component should be enabled, false otherwise