com.teamdev.jxbrowser
Interface Browser

All Superinterfaces:
ContentLoading, Disposable, Navigation, NavigationHistory, PageHost, Printing, ScriptRunner, Security
All Known Implementing Classes:
AbstractBrowser

public interface Browser
extends Navigation, NavigationHistory, ContentLoading, Printing, Security, ScriptRunner, PageHost, Disposable

The base interface for all browser engines. All browser engines must implement this interface. To find information that describes how to create a Browser instance please see the BrowserFactory class.


Method Summary
 CacheStorage getCacheStorage()
          Returns the CacheStorage for the current browser type.
 java.awt.Component getComponent()
          Returns a Swing component with embedded web browser control that allows displaying web pages.
 Configurable getConfigurable()
          Returns API enabling or disabling some browser features such as javascript, plug-ins or images etc.
 java.lang.String getContent()
          Returns the string that represents HTML content of a currently loaded document in WebBrowser.
 HttpCookieStorage getCookieStorage()
          Returns the HttpCookieStorage for the current browser type.
 org.w3c.dom.Document getDocument()
          Returns accessor for the document in the currently loaded page.
 NewWindowManager getNewWindowManager()
          Returns the current NewWindowManager instance or null if it's not present.
 BrowserServices getServices()
          Returns the global browser services instance.
 BrowserType getType()
          Returns type of current browser instance.
 void setContent(java.lang.String html)
          Sets the specified HTML content to the current Browser document.
 void setContent(java.lang.String html, java.lang.String baseURL)
          Sets the specified HTML content with the baseURI to the current Browser document.
 void setUserAgent(java.lang.String userAgent)
          Sets the user-agent string.
 java.awt.Image toImage(boolean wholePage)
          Returns an image in which the currently loaded web page is rendered.
 java.awt.Image toImage(java.awt.Dimension dimension)
          Returns an image in which the currently loaded web page is rendered.
 
Methods inherited from interface com.teamdev.jxbrowser.Navigation
addNavigationListener, getNavigationListeners, goBack, goForward, isNavigationFinished, navigate, navigate, refresh, removeNavigationListener, stop, waitReady
 
Methods inherited from interface com.teamdev.jxbrowser.NavigationHistory
addHistoryChangeListener, canGoBack, canGoForward, getAllHistory, getCurrentIndex, getCurrentLocation, getHistoryChangeListeners, removeHistoryChangeListener
 
Methods inherited from interface com.teamdev.jxbrowser.ContentLoading
addProgressListener, getProgressListeners, removeProgressListener
 
Methods inherited from interface com.teamdev.jxbrowser.print.Printing
print, print
 
Methods inherited from interface com.teamdev.jxbrowser.security.Security
getHttpSecurityHandler, setHttpSecurityHandler
 
Methods inherited from interface com.teamdev.jxbrowser.ScriptRunner
executeScript, registerFunction
 
Methods inherited from interface com.teamdev.jxbrowser.PageHost
addStatusListener, addTitleListener, getContextMenuHandler, getStatusListeners, getStatusMessage, getTitle, getTitleListeners, removeStatusListener, removeTitleListener, setContextMenuHandler
 
Methods inherited from interface com.teamdev.jxbrowser.Disposable
addDisposeListener, dispose, getDisposeListeners, isDisposed, removeDisposeListener
 

Method Detail

setContent

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

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

Parameters:
html - a string that represents HTML content to set to the current document.
See Also:
setContent(String, String), getContent(), NavigationListener.navigationFinished(NavigationFinishedEvent)

setContent

void setContent(java.lang.String html,
                java.lang.String baseURL)
Sets the specified HTML content with the baseURI to the current Browser document.

This method is executing asynchronously. To make sure that the new HTML content was applied to the document completely, use the NavigationListener.navigationFinished(NavigationFinishedEvent) event.

It may be necessary when the document contains some resources (such as images or JavaScript files) that require some time to download.

Note: This method will not set BaseURL if html string contains some HTML errors.

Parameters:
html - a string that represents HTML content to be set to the current document.
baseURL - a string that represents a default address or a default target for all links on a page.
See Also:
setContent(String), getContent(), NavigationListener.navigationFinished(NavigationFinishedEvent)

getContent

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

Returns:
the string that contains a combination of text and tags.
See Also:
setContent(String), setContent(String, String), NavigationListener.navigationFinished(NavigationFinishedEvent)

getType

BrowserType getType()
Returns type of current browser instance.

Returns:
type of current browser instance.
See Also:
BrowserType

getComponent

java.awt.Component getComponent()
Returns a Swing component with embedded web browser control that allows displaying web pages. This component can be used in Java Swing applications as standard Swing component.

The following sample demonstrates how to create a Browser instance and embed it into JFrame:

     Browser browser = BrowserFactory.createBrowser();
     JFrame frame = new JFrame();
     frame.add(browser.getComponent(), BorderLayout.CENTER);
     frame.setVisible(true);
 

Returns:
a Swing component for embedding into Java Swing applications

getDocument

org.w3c.dom.Document getDocument()
Returns accessor for the document in the currently loaded page.

Before receiving an instance of document make sure that the entire document is loaded completely. For this you can use the NavigationListener.navigationFinished(NavigationFinishedEvent) event.

Returns:
the document of the loaded web page or null if it's not present
See Also:
NavigationListener.navigationFinished(NavigationFinishedEvent)

toImage

java.awt.Image toImage(boolean wholePage)
Returns an image in which the currently loaded web page is rendered.

Parameters:
wholePage - if true returns the whole page, not just what is visible
Returns:
an image in which the currently loaded web page is rendered

toImage

java.awt.Image toImage(java.awt.Dimension dimension)
Returns an image in which the currently loaded web page is rendered.

Parameters:
dimension - - dimension of area to render, in CSS pixels
Returns:
an image in which the currently loaded web page is rendered

getNewWindowManager

NewWindowManager getNewWindowManager()
Returns the current NewWindowManager instance or null if it's not present. To set the specified NewWindowManager implementation see the BrowserServices.setNewWindowManager(NewWindowManager) method.

Returns:
the current NewWindowManager instance or null if it's not present.
See Also:
BrowserServices.setNewWindowManager(NewWindowManager), BrowserServices.getNewWindowManager(), getServices()

getServices

BrowserServices getServices()
Returns the global browser services instance. As an alternative you can use the BrowserServices.getInstance() method.

Returns:
the global browser services instance.
See Also:
BrowserServices.getInstance()

getCookieStorage

HttpCookieStorage getCookieStorage()
Returns the HttpCookieStorage for the current browser type.

Returns:
the HttpCookieStorage instance.
Throws:
UnsupportedBrowserTypeException - when the current browserType doesn't provide any cookie storage.
See Also:
getType(), BrowserServices.getCookieStorage(BrowserType)

getConfigurable

Configurable getConfigurable()
Returns API enabling or disabling some browser features such as javascript, plug-ins or images etc.

Returns:
entry point for configuring the content settings

setUserAgent

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.
Throws:
java.lang.NullPointerException - when userAgent is null.

getCacheStorage

CacheStorage getCacheStorage()
Returns the CacheStorage for the current browser type.

Returns:
the CacheStorage instance.
Throws:
UnsupportedBrowserTypeException - when the current browserType doesn't provide any cache storage.
See Also:
getType(), BrowserServices.getCacheStorage(BrowserType)