Top Description Fields Constructors Methods
org.eclipse.swt.browser

public Class Browser

extends Composite
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.widgets.*

Instances of this class implement the browser user interface metaphor. It allows the user to visualize and navigate through HTML documents.

Note that although this class is a subclass of Composite, it does not make sense to set a layout on it.

Styles:
NONE, WEBKIT
Events:
CloseWindowListener, LocationListener, OpenWindowListener, ProgressListener, StatusTextListener, TitleListener, VisibilityWindowListener

Important Note

This class is not intended to be subclassed.

Since
3.0
See Also
Browser snippets, SWT Examples: ControlExample, BrowserExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv static int
pack-priv boolean
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv int
pack-priv WebBrowser
Inherited from org.eclipse.swt.widgets.Composite:
embeddedHandle

Constructor Summary

AccessConstructor and Description
public
Browser(Composite
a widget which will be the parent of the new instance (cannot be null)
parent
,
int
the style of widget to construct
style
)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Method Summary

Modifier and TypeMethod and Description
public void
addAuthenticationListener(AuthenticationListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when authentication is required.

public void
addCloseWindowListener(CloseWindowListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when the window hosting the receiver should be closed.

public void
addLocationListener(LocationListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when the current location has changed or is about to change.

public void
addOpenWindowListener(OpenWindowListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when a new window needs to be created.

public void
addProgressListener(ProgressListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when a progress is made during the loading of the current URL or when the loading of the current URL has been completed.

public void
addStatusTextListener(StatusTextListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when the status text is changed.

public void
addTitleListener(TitleListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when the title of the current document is available or has changed.

public void
addVisibilityWindowListener(VisibilityWindowListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when a window hosting the receiver needs to be displayed or hidden.

public boolean

Returns:

true if the operation was successful and false otherwise
back
()

Navigate to the previous session history item.

pack-priv static Composite
pack-priv static int
protected void
checkSubclass()

Overrides org.eclipse.swt.widgets.Composite.checkSubclass.

Checks that this class can be subclassed.
protected void
checkWidget()

Overrides org.eclipse.swt.widgets.Widget.checkWidget.

Throws an SWTException if the receiver can not be accessed by the caller.
public static void
clearSessions()

Clears all session cookies from all current Browser instances.

public boolean

Returns:

true if the receiver was disposed, and false otherwise
close
()

Attempts to dispose the receiver, but allows the dispose to be vetoed by the user in response to an onbeforeunload listener in the Browser's current page.

public Object

Returns:

the return value, if any, of executing the script
evaluate
(String
the script with javascript commands
script
)

Returns the result, if any, of executing the specified script.

public Object

Returns:

the return value, if any, of executing the script
evaluate
(String
the script with javascript commands
script
,
boolean
true or false depending on the security context to be used
trusted
)

Returns the result, if any, of executing the specified script.

public boolean

Returns:

true if the operation was successful and false otherwise
execute
(String
the script with javascript commands
script
)

Executes the specified script.

public boolean

Returns:

true if the operation was successful and false otherwise
forward
()

Navigate to the next session history item.

public String

Returns:

the type of the native browser
getBrowserType
()

Returns the type of native browser being used by this instance.

public static String

Returns:

the cookie value, or null if no such cookie exists
getCookie
(String
the cookie name
name
,
String
the URL that the cookie is associated with
url
)

Returns the value of a cookie that is associated with a URL.

public boolean

Returns:

the receiver's javascript enabled state
getJavascriptEnabled
()

Returns true if javascript will be allowed to run in pages subsequently viewed in the receiver, and false otherwise.

public int
getStyle()

Overrides org.eclipse.swt.widgets.Widget.getStyle.

Returns the receiver's style information.
public String

Returns:

HTML representing the current page or an empty String if this is empty.

Note, the exact return value is platform dependent. For example on Windows, the returned string is the proccessed webpage with javascript executed and missing html tags added. On Linux and OS X, this returns the original HTML before the browser has processed it.

getText
()

Returns a string with HTML that represents the content of the current page.

public String

Returns:

the current URL or an empty String if there is no current URL
getUrl
()

Returns the current URL.

public Object

Returns:

the receiver's JavaXPCOM nsIWebBrowser or null
getWebBrowser
()

Deprecated SWT.MOZILLA is deprecated and XULRunner as a browser renderer is no longer supported.
Returns the JavaXPCOM nsIWebBrowser for the receiver, or null if it is not available.
public boolean

Returns:

the receiver's back command enabled state
isBackEnabled
()

Returns true if the receiver can navigate to the previous session history item, and false otherwise.

public boolean
isFocusControl()

Overrides org.eclipse.swt.widgets.Control.isFocusControl.

Returns true if the receiver has the user-interface focus, and false otherwise.
public boolean

Returns:

the receiver's forward command enabled state
isForwardEnabled
()

Returns true if the receiver can navigate to the next session history item, and false otherwise.

public void
refresh()

Refresh the current page.

public void
removeAuthenticationListener(AuthenticationListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when authentication is required.

public void
removeCloseWindowListener(CloseWindowListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the window hosting the receiver should be closed.

public void
removeLocationListener(LocationListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the current location is changed or about to be changed.

public void
removeOpenWindowListener(OpenWindowListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when a new window needs to be created.

public void
removeProgressListener(ProgressListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when a progress is made during the loading of the current URL or when the loading of the current URL has been completed.

public void
removeStatusTextListener(StatusTextListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the status text is changed.

public void
removeTitleListener(TitleListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the title of the current document is available or has changed.

public void
removeVisibilityWindowListener(VisibilityWindowListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when a window hosting the receiver needs to be displayed or hidden.

public static boolean

Returns:

true if the cookie was successfully set and false otherwise
setCookie
(String
the cookie value
value
,
String
the URL to associate the cookie with
url
)

Sets a cookie on a URL.

public void
setJavascriptEnabled(boolean
the receiver's new javascript enabled state
enabled
)

Sets whether javascript will be allowed to run in pages subsequently viewed in the receiver.

public boolean

Returns:

true if the operation was successful and false otherwise.
setText
(String
the HTML content to be rendered
html
)

Renders a string containing HTML.

public boolean

Returns:

true if the operation was successful and false otherwise.
setText
(String
the HTML content to be rendered
html
,
boolean
false if the rendered page should be granted restricted permissions and true otherwise
trusted
)

Renders a string containing HTML.

public boolean

Returns:

true if the operation was successful and false otherwise.
setUrl
(String
the URL to be loaded
url
)

Begins loading a URL.

public boolean

Returns:

true if the operation was successful and false otherwise.
setUrl
(String
the URL to be loaded
url
,
String
post data to be sent with the request, or null
postData
,
String[]
header lines to be sent with the request, or null
headers
)

Begins loading a URL.

public void
stop()

Stop any loading and rendering activity.

Inherited from org.eclipse.swt.widgets.Composite:
changeddrawBackgroundgetBackgroundModegetChildrengetLayoutgetLayoutDeferredgetTabListisLayoutDeferredlayoutlayoutlayoutlayoutlayoutsetBackgroundModesetFocussetLayoutsetLayoutDeferredsetTabListtoString

Field Detail

DefaultTypeback to summary
pack-priv static int DefaultType
isClosingback to summary
pack-priv boolean isClosing
NO_INPUT_METHODback to summary
pack-priv static final String NO_INPUT_METHOD

Hides org.eclipse.swt.widgets.Composite.NO_INPUT_METHOD.

PACKAGE_PREFIXback to summary
pack-priv static final String PACKAGE_PREFIX
PROPERTY_DEFAULTTYPEback to summary
pack-priv static final String PROPERTY_DEFAULTTYPE
userStyleback to summary
pack-priv int userStyle
webBrowserback to summary
pack-priv WebBrowser webBrowser

Constructor Detail

Browserback to summary
public Browser(Composite parent, int style)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters
parent:Composite

a widget which will be the parent of the new instance (cannot be null)

style:int

the style of widget to construct

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parent is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
SWTError:
  • ERROR_NO_HANDLES if a handle could not be obtained for browser creation
Since
3.0
See Also
Widget#getStyle

Method Detail

addAuthenticationListenerback to summary
public void addAuthenticationListener(AuthenticationListener listener)

Adds the listener to the collection of listeners who will be notified when authentication is required.

This notification occurs when a page requiring authentication is encountered.

Parameters
listener:AuthenticationListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.5
addCloseWindowListenerback to summary
public void addCloseWindowListener(CloseWindowListener listener)

Adds the listener to the collection of listeners who will be notified when the window hosting the receiver should be closed.

This notification occurs when a javascript command such as window.close gets executed by a Browser.

Parameters
listener:CloseWindowListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
addLocationListenerback to summary
public void addLocationListener(LocationListener listener)

Adds the listener to the collection of listeners who will be notified when the current location has changed or is about to change.

This notification typically occurs when the application navigates to a new location with setUrl(String) or when the user activates a hyperlink.

Parameters
listener:LocationListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
addOpenWindowListenerback to summary
public void addOpenWindowListener(OpenWindowListener listener)

Adds the listener to the collection of listeners who will be notified when a new window needs to be created.

This notification occurs when a javascript command such as window.open gets executed by a Browser.

Parameters
listener:OpenWindowListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
addProgressListenerback to summary
public void addProgressListener(ProgressListener listener)

Adds the listener to the collection of listeners who will be notified when a progress is made during the loading of the current URL or when the loading of the current URL has been completed.

Parameters
listener:ProgressListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
addStatusTextListenerback to summary
public void addStatusTextListener(StatusTextListener listener)

Adds the listener to the collection of listeners who will be notified when the status text is changed.

The status text is typically displayed in the status bar of a browser application.

Parameters
listener:StatusTextListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
addTitleListenerback to summary
public void addTitleListener(TitleListener listener)

Adds the listener to the collection of listeners who will be notified when the title of the current document is available or has changed.

Parameters
listener:TitleListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
addVisibilityWindowListenerback to summary
public void addVisibilityWindowListener(VisibilityWindowListener listener)

Adds the listener to the collection of listeners who will be notified when a window hosting the receiver needs to be displayed or hidden.

Parameters
listener:VisibilityWindowListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
backback to summary
public boolean back()

Navigate to the previous session history item.

Returns:boolean

true if the operation was successful and false otherwise

Exceptions
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
See Also
forward
checkParentback to summary
pack-priv static Composite checkParent(Composite parent)
checkStyleback to summary
pack-priv static int checkStyle(int style)

Hides org.eclipse.swt.widgets.Composite.checkStyle.

checkSubclassback to summary
protected void checkSubclass()

Overrides org.eclipse.swt.widgets.Composite.checkSubclass.

Doc from org.eclipse.swt.widgets.Widget.checkSubclass.

Checks that this class can be subclassed.

The SWT class library is intended to be subclassed only at specific, controlled points (most notably, Composite and Canvas when implementing new widgets). This method enforces this rule unless it is overridden.

Important Note

By providing an implementation of this method that allows a subclass of a class which does not normally allow subclassing to be created, the implementer agrees to be fully responsible for the fact that any such subclass will likely fail between SWT releases and will be strongly platform specific. No support is provided for user-written classes which are implemented in this fashion.

The ability to subclass outside of the allowed SWT classes is intended purely to enable those not on the SWT development team to implement patches in order to get around specific limitations in advance of when those limitations can be addressed by the team. Subclassing should not be attempted without an intimate and detailed understanding of the hierarchy.

Annotations
@Override
checkWidgetback to summary
protected void checkWidget()

Overrides org.eclipse.swt.widgets.Widget.checkWidget.

Doc from org.eclipse.swt.widgets.Widget.checkWidget.

Throws an SWTException if the receiver can not be accessed by the caller. This may include both checks on the state of the receiver and more generally on the entire execution context. This method should be called by widget implementors to enforce the standard SWT invariants.

Currently, it is an error to invoke any method (other than isDisposed()) on a widget that has had its dispose() method called. It is also an error to call widget methods from any thread that is different from the thread that created the widget.

In future releases of SWT, there may be more or fewer error checks and exceptions may be thrown for different reasons.

Annotations
@Override
clearSessionsback to summary
public static void clearSessions()

Clears all session cookies from all current Browser instances.

Since
3.2
closeback to summary
public boolean close()

Attempts to dispose the receiver, but allows the dispose to be vetoed by the user in response to an onbeforeunload listener in the Browser's current page.

Returns:boolean

true if the receiver was disposed, and false otherwise

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since
3.6
See Also
dispose()
evaluateback to summary
public Object evaluate(String script) throws SWTException

Returns the result, if any, of executing the specified script.

Evaluates a script containing javascript commands in the context of the current document. If document-defined functions or properties are accessed by the script then this method should not be invoked until the document has finished loading (ProgressListener.completed() gives notification of this).

If the script returns a value with a supported type then a java representation of the value is returned. The supported javascript -> java mappings are:

  • javascript null or undefined -> null
  • javascript number -> java.lang.Double
  • javascript string -> java.lang.String
  • javascript boolean -> java.lang.Boolean
  • javascript array whose elements are all of supported types -> java.lang.Object[]
An SWTException is thrown if the return value has an unsupported type, or if evaluating the script causes a javascript error to be thrown.
Parameters
script:String

the script with javascript commands

Returns:Object

the return value, if any, of executing the script

Exceptions
SWTException:
  • ERROR_FAILED_EVALUATE when the script evaluation causes a javascript error to be thrown
  • ERROR_INVALID_RETURN_VALUE when the script returns a value of unsupported type
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the script is null
Since
3.5
See Also
Browser#evaluate(String, boolean), ProgressListener#completed(ProgressEvent)
evaluateback to summary
public Object evaluate(String script, boolean trusted) throws SWTException

Returns the result, if any, of executing the specified script.

Evaluates a script containing javascript commands. When trusted is true script is executed in the context of Chrome with Chrome security privileges. When trusted is false script is executed in the context of the current document with normal privileges.

If document-defined functions or properties are accessed by the script then this method should not be invoked until the document has finished loading (ProgressListener.completed() gives notification of this).

If the script returns a value with a supported type then a java representation of the value is returned. The supported javascript -> java mappings are:

  • javascript null or undefined -> null
  • javascript number -> java.lang.Double
  • javascript string -> java.lang.String
  • javascript boolean -> java.lang.Boolean
  • javascript array whose elements are all of supported types -> java.lang.Object[]
An SWTException is thrown if the return value has an unsupported type, or if evaluating the script causes a javascript error to be thrown.
Parameters
script:String

the script with javascript commands

trusted:boolean

true or false depending on the security context to be used

Returns:Object

the return value, if any, of executing the script

Exceptions
SWTException:
  • ERROR_FAILED_EVALUATE when the script evaluation causes a javascript error to be thrown
  • ERROR_INVALID_RETURN_VALUE when the script returns a value of unsupported type
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the script is null
See Also
ProgressListener#completed(ProgressEvent)
executeback to summary
public boolean execute(String script)

Executes the specified script.

Executes a script containing javascript commands in the context of the current document. If document-defined functions or properties are accessed by the script then this method should not be invoked until the document has finished loading (ProgressListener.completed() gives notification of this).

Parameters
script:String

the script with javascript commands

Returns:boolean

true if the operation was successful and false otherwise

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the script is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.1
See Also
ProgressListener#completed(ProgressEvent)
forwardback to summary
public boolean forward()

Navigate to the next session history item.

Returns:boolean

true if the operation was successful and false otherwise

Exceptions
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
See Also
back
getBrowserTypeback to summary
public String getBrowserType()

Returns the type of native browser being used by this instance. Examples: "ie", "webkit"

Returns:String

the type of the native browser

Since
3.5
getCookieback to summary
public static String getCookie(String name, String url)

Returns the value of a cookie that is associated with a URL. Note that cookies are shared amongst all Browser instances.

Parameters
name:String

the cookie name

url:String

the URL that the cookie is associated with

Returns:String

the cookie value, or null if no such cookie exists

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the name is null
  • ERROR_NULL_ARGUMENT - if the url is null
Since
3.5
getJavascriptEnabledback to summary
public boolean getJavascriptEnabled()

Returns true if javascript will be allowed to run in pages subsequently viewed in the receiver, and false otherwise. Note that this may not reflect the javascript enablement on the currently- viewed page if setJavascriptEnabled() has been invoked during its lifetime.

Returns:boolean

the receiver's javascript enabled state

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since
3.5
See Also
setJavascriptEnabled
getStyleback to summary
public int getStyle()

Overrides org.eclipse.swt.widgets.Widget.getStyle.

Doc from org.eclipse.swt.widgets.Widget.getStyle.

Returns the receiver's style information.

Note that the value which is returned by this method may not match the value which was provided to the constructor when the receiver was created. This can occur when the underlying operating system does not support a particular combination of requested styles. For example, if the platform widget used to implement a particular SWT widget always has scroll bars, the result of calling this method would always have the SWT.H_SCROLL and SWT.V_SCROLL bits set.

Returns:int

the style bits

Annotations
@Override
getTextback to summary
public String getText()

Returns a string with HTML that represents the content of the current page.

Returns:String

HTML representing the current page or an empty String if this is empty.

Note, the exact return value is platform dependent. For example on Windows, the returned string is the proccessed webpage with javascript executed and missing html tags added. On Linux and OS X, this returns the original HTML before the browser has processed it.

Exceptions
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.4
getUrlback to summary
public String getUrl()

Returns the current URL.

Returns:String

the current URL or an empty String if there is no current URL

Exceptions
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
See Also
setUrl
getWebBrowserback to summary
public Object getWebBrowser()

Deprecated

SWT.MOZILLA is deprecated and XULRunner as a browser renderer is no longer supported.

Returns the JavaXPCOM nsIWebBrowser for the receiver, or null if it is not available. In order for an nsIWebBrowser to be returned all of the following must be true:

  • the receiver's style must be SWT.MOZILLA
  • the classes from JavaXPCOM >= 1.8.1.2 must be resolvable at runtime
  • the version of the underlying XULRunner must be >= 1.8.1.2
Returns:Object

the receiver's JavaXPCOM nsIWebBrowser or null

Annotations
@Deprecated
Since
3.3
isBackEnabledback to summary
public boolean isBackEnabled()

Returns true if the receiver can navigate to the previous session history item, and false otherwise.

Returns:boolean

the receiver's back command enabled state

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also
back
isFocusControlback to summary
public boolean isFocusControl()

Overrides org.eclipse.swt.widgets.Control.isFocusControl.

Doc from org.eclipse.swt.widgets.Control.isFocusControl.

Returns true if the receiver has the user-interface focus, and false otherwise.

Returns:boolean

the receiver's focus state

Annotations
@Override
isForwardEnabledback to summary
public boolean isForwardEnabled()

Returns true if the receiver can navigate to the next session history item, and false otherwise.

Returns:boolean

the receiver's forward command enabled state

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also
forward
refreshback to summary
public void refresh()

Refresh the current page.

Exceptions
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
removeAuthenticationListenerback to summary
public void removeAuthenticationListener(AuthenticationListener listener)

Removes the listener from the collection of listeners who will be notified when authentication is required.

Parameters
listener:AuthenticationListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.5
removeCloseWindowListenerback to summary
public void removeCloseWindowListener(CloseWindowListener listener)

Removes the listener from the collection of listeners who will be notified when the window hosting the receiver should be closed.

Parameters
listener:CloseWindowListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
removeLocationListenerback to summary
public void removeLocationListener(LocationListener listener)

Removes the listener from the collection of listeners who will be notified when the current location is changed or about to be changed.

Parameters
listener:LocationListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
removeOpenWindowListenerback to summary
public void removeOpenWindowListener(OpenWindowListener listener)

Removes the listener from the collection of listeners who will be notified when a new window needs to be created.

Parameters
listener:OpenWindowListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
removeProgressListenerback to summary
public void removeProgressListener(ProgressListener listener)

Removes the listener from the collection of listeners who will be notified when a progress is made during the loading of the current URL or when the loading of the current URL has been completed.

Parameters
listener:ProgressListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
removeStatusTextListenerback to summary
public void removeStatusTextListener(StatusTextListener listener)

Removes the listener from the collection of listeners who will be notified when the status text is changed.

Parameters
listener:StatusTextListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
removeTitleListenerback to summary
public void removeTitleListener(TitleListener listener)

Removes the listener from the collection of listeners who will be notified when the title of the current document is available or has changed.

Parameters
listener:TitleListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
removeVisibilityWindowListenerback to summary
public void removeVisibilityWindowListener(VisibilityWindowListener listener)

Removes the listener from the collection of listeners who will be notified when a window hosting the receiver needs to be displayed or hidden.

Parameters
listener:VisibilityWindowListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
setCookieback to summary
public static boolean setCookie(String value, String url)

Sets a cookie on a URL. Note that cookies are shared amongst all Browser instances. The value parameter must be a cookie header string that complies with RFC 2109. The value is passed through to the native browser unchanged.

Example value strings: foo=bar (basic session cookie) foo=bar; path=/; domain=.eclipse.org (session cookie) foo=bar; expires=Tue, 01-Jan-2030 00:00:01 GMT (persistent cookie) foo=; expires=Thu, 01-Jan-1970 00:00:01 GMT (deletes cookie foo)

Parameters
value:String

the cookie value

url:String

the URL to associate the cookie with

Returns:boolean

true if the cookie was successfully set and false otherwise

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the value is null
  • ERROR_NULL_ARGUMENT - if the url is null
Since
3.5
setJavascriptEnabledback to summary
public void setJavascriptEnabled(boolean enabled)

Sets whether javascript will be allowed to run in pages subsequently viewed in the receiver. Note that setting this value does not affect the running of javascript in the current page.

Parameters
enabled:boolean

the receiver's new javascript enabled state

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since
3.5
setTextback to summary
public boolean setText(String html)

Renders a string containing HTML. The rendering of the content occurs asynchronously. The rendered page will be given trusted permissions; to render the page with untrusted permissions use setText(String html, boolean trusted) instead.

The html parameter is Unicode-encoded since it is a java String. As a result, the HTML meta tag charset should not be set. The charset is implied by the String itself.

Parameters
html:String

the HTML content to be rendered

Returns:boolean

true if the operation was successful and false otherwise.

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the html is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
See Also
setText(String, boolean), setUrl
setTextback to summary
public boolean setText(String html, boolean trusted)

Renders a string containing HTML. The rendering of the content occurs asynchronously. The rendered page can be given either trusted or untrusted permissions.

The html parameter is Unicode-encoded since it is a java String. As a result, the HTML meta tag charset should not be set. The charset is implied by the String itself.

The trusted parameter affects the permissions that will be granted to the rendered page. Specifying true for trusted gives the page permissions equivalent to a page on the local file system, while specifying false for trusted gives the page permissions equivalent to a page from the internet. Page content should be specified as trusted if the invoker created it or trusts its source, since this would allow (for instance) style sheets on the local file system to be referenced. Page content should be specified as untrusted if its source is not trusted or is not known.

Parameters
html:String

the HTML content to be rendered

trusted:boolean

false if the rendered page should be granted restricted permissions and true otherwise

Returns:boolean

true if the operation was successful and false otherwise.

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the html is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.6
See Also
setText(String), setUrl
setUrlback to summary
public boolean setUrl(String url)

Begins loading a URL. The loading of its content occurs asynchronously.

Parameters
url:String

the URL to be loaded

Returns:boolean

true if the operation was successful and false otherwise.

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the url is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0
See Also
getUrl, setUrl(String, String, String[])
setUrlback to summary
public boolean setUrl(String url, String postData, String[] headers)

Begins loading a URL. The loading of its content occurs asynchronously.

If the URL causes an HTTP request to be initiated then the provided postData and header arguments, if any, are sent with the request. A value in the headers argument must be a name-value pair with a colon separator in order to be sent (for example: "user-agent: custom").

Parameters
url:String

the URL to be loaded

postData:String

post data to be sent with the request, or null

headers:String[]

header lines to be sent with the request, or null

Returns:boolean

true if the operation was successful and false otherwise.

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the url is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.6
stopback to summary
public void stop()

Stop any loading and rendering activity.

Exceptions
SWTException:
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
Since
3.0