com.jniwrapper.win32.ie
Class Browser

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

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/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Nested classes/interfaces inherited from interface 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 a new Browser instance.
Browser(Browser parent)
          Creates a child browser instance.
Browser(BrowserOptions options)
          Creates a new Browser instance using entire browser options.
 
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 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<Cookie> getCookies(java.lang.String url)
          Deprecated. Use the CookieManager.getCookies(URL url) method instead.
 java.util.Set<Cookie> getCookies(java.net.URL url)
          Returns cookies, that are associated with the specified URL.
 java.lang.String getDefaultUserAgent()
          Returns the default user-agent string.
 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.
 HtmlDialogListener getHtmlDialogListener()
          Returns the current HTML Dialog listener or null 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<NavigationEventListener> getNavigationListeners()
          Returns browser navigation event listeners.
 NewWindowEventHandler getNewWindowHandler()
          Returns new window handler.
 java.util.List<NewWindowEventListener> getNewWindowListeners()
          Returns new window listeners.
 com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
          Return browser OLE message loop.
 BrowserOptions getOptions()
           
 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.
 java.awt.Image getScreenShot(java.awt.Dimension dimension)
          Returns an image that represent screen shot of the page.
 ScriptErrorListener getScriptErrorListener()
          Returns script error listener for current page.
 java.util.List<StatusEventListener> getStatusListeners()
          Returns browser status event listeners.
 java.lang.String getUserAgent()
          Returns the user-agent string.
 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 isClosing()
           
 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.
protected  void processComponentKeyEvent(java.awt.event.KeyEvent e)
           
 void refresh()
          Reloads the file that is currently displayed in the object.
 void registerFunction(java.lang.String functionName, BrowserFunction function)
          Registers a browser function on the currently loaded document.
 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 removeNotify()
           
 void removeStatusListener(StatusEventListener listener)
          Removes browser status event listener.
 void requestFocus()
           
 void setAuthenticationHandler(AuthenticationHandler handler)
          Sets the specified browser authentication handler.
 void setClosing(boolean closing)
           
 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 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 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 setUserAgent(java.lang.String userAgent)
          Sets the user-agent string.
 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 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()
          Causes a current thread to wait for the completion of the current operation in the browser.
 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, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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 a new Browser instance. The instance will be configured with default browser options values.

See Also:
Browser(BrowserOptions)

Browser

public Browser(BrowserOptions options)
Creates a new Browser instance using entire browser options.

Parameters:
options - the browser instance options.

Browser

public Browser(Browser parent)
Creates a child browser instance. In this case child browser instance will use parent's browser options.

Parameters:
parent - the parent for the child browser.
Throws:
java.lang.NullPointerException - when parent is null.
Method Detail

requestFocus

public void requestFocus()
Overrides:
requestFocus in class javax.swing.JComponent

getOptions

public BrowserOptions getOptions()

removeNotify

public void removeNotify()
Overrides:
removeNotify in class javax.swing.JComponent

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class javax.swing.JComponent

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.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.

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)

navigate

public void navigate(java.lang.String location,
                     java.lang.String targetName,
                     java.lang.String postData,
                     java.lang.String headers)
Description copied from interface: WebBrowser
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").
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.
See Also:
WebBrowser.navigate(String), WebBrowser.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 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.

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:
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()
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<NavigationEventListener> 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<StatusEventListener> 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 IllegalStateException error. Use this method when you don't need the WebBrowser instance anymore.

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

isClosing

public boolean isClosing()

setClosing

public void setClosing(boolean closing)

isClosed

public 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 can can invoke its methods.

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

getCookies

public java.util.Set<Cookie> getCookies(java.net.URL url)
Description copied from interface: WebBrowser
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.

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

setCookies

public void setCookies(java.net.URL url,
                       java.util.Set<Cookie> cookies)
Description copied from interface: WebBrowser
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.

Specified by:
setCookies in interface WebBrowser
Parameters:
url - specifies an URL, a new cookie will be associated with.
cookies - the collection of Cookie objects.

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)

addDisposeListener

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

Specified by:
addDisposeListener in interface WebBrowser
Parameters:
listener - the listener to receive browser dispose events.

removeDisposeListener

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

Specified by:
removeDisposeListener in interface WebBrowser
Parameters:
listener - the listener to remove.

getDisposeListeners

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

Specified by:
getDisposeListeners in interface WebBrowser
Returns:
an array of all registered listeners for the current Browser instance.

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 window.showModalDialog and window.showModelessDialog JavaScript functions.

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

getHtmlDialogListener

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

Returns:
the current HTML Dialog listener or null 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<NewWindowEventListener> 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<Cookie> 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

getScreenShot

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

Parameters:
dimension - - dimension of area to render
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

setUserAgent

public void setUserAgent(java.lang.String userAgent)
Sets the user-agent string.

The user-agent string is used by websites to identify the client browser.

Parameters:
userAgent - the user-agent string.
See Also:
getUserAgent()

getUserAgent

public java.lang.String getUserAgent()
Returns the user-agent string.

The user-agent string is used by websites to identify the client browser.

Returns:
the current user-agent string.
See Also:
setUserAgent(String)

getDefaultUserAgent

public java.lang.String getDefaultUserAgent()
Returns the default user-agent string.

The user-agent string is used by websites to identify the client browser.

Returns:
the MS Internet Explorer default user-agent string.
See Also:
setUserAgent(String)

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.

Overrides:
setEnabled in class javax.swing.JComponent
Parameters:
enabled - true if this component should be enabled, false otherwise

registerFunction

public void registerFunction(java.lang.String functionName,
                             BrowserFunction function)
Registers a browser function on the currently loaded document. This function can be invoked on JavaScript side via its functionName. The browser function is not available anymore if document is reloaded or other web page is loaded.

Parameters:
functionName -
function -

getZoomValue

public int getZoomValue()
Specified by:
getZoomValue in interface WebBrowser

setZoomValue

public void setZoomValue(int value)
Specified by:
setZoomValue in interface WebBrowser

processComponentKeyEvent

protected void processComponentKeyEvent(java.awt.event.KeyEvent e)
Overrides:
processComponentKeyEvent in class javax.swing.JComponent