|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel chrriis.dj.nativeswing.swtimpl.NSPanelComponent chrriis.dj.nativeswing.swtimpl.components.JWebBrowser
public class JWebBrowser
A native web browser, using Internet Explorer or Mozilla on Windows, and Mozilla on other platforms.
Methods execute when this component is initialized. If the component is not initialized, methods will be executed as soon as it gets initialized.
If the initialization fails, the methods will not have any effect. The results from methods have relevant values only when the component is valid.
Nested Class Summary | |
---|---|
static interface |
JWebBrowser.WebBrowserDecoratorFactory
A factory that creates the decorators for web browsers. |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
COMMAND_FUNCTION
The function to use when sending a command from some web content using Javascript. |
static String |
COMMAND_LOCATION_PREFIX
The prefix to use when sending a command from some web content, using a static link or by setting window.location from Javascript. |
static String |
COMMAND_STATUS_PREFIX
The prefix to use when sending a command from some web content, by setting window.status from Javascript. |
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 | |
---|---|
JWebBrowser(NSOption... options)
Construct a new web browser. |
Method Summary | |
---|---|
void |
addWebBrowserListener(WebBrowserListener listener)
Add a web browser listener. |
static void |
clearSessionCookies()
Clear all session cookies from all web browser instances. |
static String |
convertJavaObjectToJavascript(Object o)
Convert a Java object to Javascript, to simplify the task of executing scripts. |
static void |
copyAppearance(JWebBrowser fromWebBrowser,
JWebBrowser toWebBrowser)
Copy the appearance, the visibility of the various bars, from one web browser to another. |
static void |
copyContent(JWebBrowser fromWebBrowser,
JWebBrowser toWebBrowser)
Copy the content, whether a URL or its HTML content, from one web browser to another. |
static String |
createJavascriptFunctionCall(String functionName,
Object... args)
Create the Javascript function call using the function name and Java objects as arguments. |
protected WebBrowserDecorator |
createWebBrowserDecorator(Component renderingComponent)
Create a decorator for this web browser. |
boolean |
disposeNativePeer(boolean isConfirmationDialogAllowed)
Dispose the native peer but potentially allows confirmation dialog to the user. |
void |
executeJavascript(String javascript)
Execute some javascript. |
Object |
executeJavascriptWithResult(String javascript)
Execute some javascript, and wait for the result coming from the return statements. |
WebBrowserAuthenticationHandler |
getAuthenticationHandler()
Get the authentication handler or null if none is set. |
String |
getBrowserType()
Get the type of browser (ie, mozilla, etc.). |
String |
getBrowserVersion()
Get the version of the browser. |
static String |
getCookie(String url,
String name)
Get a cookie for a given URL and a given name. |
String |
getHTMLContent()
Get the HTML content. |
int |
getLoadingProgress()
Get the loading progress, a value between 0 and 100, where 100 means it is fully loaded. |
String |
getPageTitle()
Get the title of the web page. |
String |
getResourceLocation()
Get the location of the resource currently displayed. |
String |
getStatusText()
Get the status text. |
WebBrowserListener[] |
getWebBrowserListeners()
Get the web browser listeners. |
JWebBrowserWindow |
getWebBrowserWindow()
Get the web browser window if the web browser is contained in one. |
boolean |
isBackNavigationEnabled()
Indicate if the web browser Back functionality is enabled. |
boolean |
isButtonBarVisible()
Indicate whether the button bar is visible. |
boolean |
isForwardNavigationEnabled()
Indicate if the web browser Forward functionality is enabled. |
boolean |
isJavascriptEnabled()
Indicate if Javascript will be allowed to run in pages subsequently viewed. |
boolean |
isLocationBarVisible()
Indicate whether the location bar is visible. |
boolean |
isMenuBarVisible()
Indicate whether the menu bar is visible. |
boolean |
isStatusBarVisible()
Indicate whether the status bar is visible. |
boolean |
navigate(String resourceLocation)
Navigate to a resource, with its location specified as a URL or path. |
boolean |
navigate(String resourceLocation,
WebBrowserNavigationParameters parameters)
Navigate to a resource, with its location specified as a URL or path. |
void |
navigateBack()
Invoke the web browser Back functionality. |
void |
navigateForward()
Invoke the web browser Forward functionality. |
boolean |
print(boolean isShowingDialog)
Attempt to print the content of the currently loaded page specifying whether to show the print dialog. |
void |
registerFunction(WebBrowserFunction function)
Register a function to the web browser which can be called from Javascript. |
void |
reloadPage()
Invoke the web browser Reload functionality. |
void |
removeWebBrowserListener(WebBrowserListener listener)
Remove a web browser listener. |
void |
setAuthenticationHandler(WebBrowserAuthenticationHandler authenticationHandler)
Set the authentication handler. |
void |
setBarsVisible(boolean areBarsVisible)
Show or hide all the bars at once. |
void |
setButtonBarVisible(boolean isButtonBarVisible)
Set whether the button bar is visible. |
static void |
setCookie(String url,
String value)
Set a cookie for all web browser instances. |
void |
setDefaultPopupMenuRegistered(boolean isDefaultPopupMenuRegistered)
Set whether this component is able to detect a popup menu gesture to show its default popup menu. |
boolean |
setHTMLContent(String html)
Set the HTML content. |
void |
setJavascriptEnabled(boolean isJavascriptEnabled)
Set whether javascript will be allowed to run in pages subsequently. |
void |
setLocationBarVisible(boolean isLocationBarVisible)
Set whether the location bar is visible. |
void |
setMenuBarVisible(boolean isMenuBarVisible)
Set whether the menu bar is visible. |
void |
setStatusBarVisible(boolean isStatusBarVisible)
Set whether the status bar is visible. |
static void |
setWebBrowserDecoratorFactory(JWebBrowser.WebBrowserDecoratorFactory webBrowserDecoratorFactory)
Set the decorator that will be used for future web browser instances. |
void |
stopLoading()
Invoke the web browser Stop functionality, to stop all current loading operations. |
void |
unregisterFunction(WebBrowserFunction function)
Unregister a function from the web browser, which cannot be called from Javascript anymore. |
static NSOption |
useWebkitRuntime()
Create an option to make the web browser use the Webkit runtime. |
static NSOption |
useXULRunnerRuntime()
Create an option to make the web browser use the Mozilla XULRunner runtime. |
Methods inherited from class chrriis.dj.nativeswing.swtimpl.NSPanelComponent |
---|
constrainVisibility, destroyOnFinalization, disposeNativePeer, getNativeComponent, initialize, initializeNativePeer, isNativePeerDisposed, isNativePeerInitialized, isNativePeerValid, proxyComponentHierarchy, runInSequence |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String COMMAND_FUNCTION
public static final String COMMAND_LOCATION_PREFIX
public static final String COMMAND_STATUS_PREFIX
Constructor Detail |
---|
public JWebBrowser(NSOption... options)
options
- the options to configure the behavior of this component.Method Detail |
---|
public static NSOption useXULRunnerRuntime()
public static NSOption useWebkitRuntime()
public static void setWebBrowserDecoratorFactory(JWebBrowser.WebBrowserDecoratorFactory webBrowserDecoratorFactory)
webBrowserDecoratorFactory
- the factory that creates the decorators, or null for default decorators.protected WebBrowserDecorator createWebBrowserDecorator(Component renderingComponent)
renderingComponent
- the component to add to the decorator's component hierarchy.
public static void clearSessionCookies()
public static String getCookie(String url, String name)
public static void setCookie(String url, String value)
url
- the url.value
- the value, in a cookie form like:
foo=bar
(basic session cookie)
foo=bar; path=/; domain=.eclipse.org
(session cookie)
foo=bar; expires=Thu, 01-Jan-2030 00:00:01 GMT
(persistent cookie)
foo=; expires=Thu, 01-Jan-1970 00:00:01 GMT
(deletes cookie foo
)public static void copyAppearance(JWebBrowser fromWebBrowser, JWebBrowser toWebBrowser)
fromWebBrowser
- the web browser to copy the appearance from.toWebBrowser
- the web browser to copy the appearance to.public static void copyContent(JWebBrowser fromWebBrowser, JWebBrowser toWebBrowser)
fromWebBrowser
- the web browser to copy the content from.toWebBrowser
- the web browser to copy the content to.public void setStatusBarVisible(boolean isStatusBarVisible)
isStatusBarVisible
- true if the status bar should be visible, false otherwise.public boolean isStatusBarVisible()
public void setMenuBarVisible(boolean isMenuBarVisible)
isMenuBarVisible
- true if the menu bar should be visible, false otherwise.public boolean isMenuBarVisible()
public void setButtonBarVisible(boolean isButtonBarVisible)
isButtonBarVisible
- true if the button bar should be visible, false otherwise.public boolean isButtonBarVisible()
public void setLocationBarVisible(boolean isLocationBarVisible)
isLocationBarVisible
- true if the location bar should be visible, false otherwise.public boolean isLocationBarVisible()
public String getPageTitle()
public String getStatusText()
public String getHTMLContent()
public boolean setHTMLContent(String html)
html
- the HTML content.public String getResourceLocation()
public boolean navigate(String resourceLocation)
resourceLocation
- the URL or path.
public boolean navigate(String resourceLocation, WebBrowserNavigationParameters parameters)
resourceLocation
- the URL or path.parameters
- the parameters (headers and POST data) to send with the navigation request.
public boolean isBackNavigationEnabled()
public void navigateBack()
public boolean isForwardNavigationEnabled()
public void navigateForward()
public void reloadPage()
public void stopLoading()
public boolean isJavascriptEnabled()
public void setJavascriptEnabled(boolean isJavascriptEnabled)
isJavascriptEnabled
- true to enable Javascript, false otherwise.public void executeJavascript(String javascript)
javascript
- the javascript to execute.public Object executeJavascriptWithResult(String javascript)
javascript
- the javascript to execute which must contain explicit return statements.
public static String createJavascriptFunctionCall(String functionName, Object... args)
functionName
- the name of the Javascript funtion.args
- the Java objects (String, number, boolean, or array) which will get converted to Javascript arguments.
public static String convertJavaObjectToJavascript(Object o)
o
- the object to convert, which can be a String, number, boolean, or array.public int getLoadingProgress()
public void setAuthenticationHandler(WebBrowserAuthenticationHandler authenticationHandler)
authenticationHandler
- The authentication handler, or null to remove the current one.public WebBrowserAuthenticationHandler getAuthenticationHandler()
public void addWebBrowserListener(WebBrowserListener listener)
listener
- The web browser listener to add.public void removeWebBrowserListener(WebBrowserListener listener)
listener
- the web browser listener to remove.public WebBrowserListener[] getWebBrowserListeners()
public void setBarsVisible(boolean areBarsVisible)
areBarsVisible
- true to show all bars, false to hide them all.public JWebBrowserWindow getWebBrowserWindow()
public void setDefaultPopupMenuRegistered(boolean isDefaultPopupMenuRegistered)
isDefaultPopupMenuRegistered
- true if the default popup menu is registered.public void registerFunction(WebBrowserFunction function)
function
- the function to add.public void unregisterFunction(WebBrowserFunction function)
function
- the function to remove.public String getBrowserType()
public String getBrowserVersion()
public boolean disposeNativePeer(boolean isConfirmationDialogAllowed)
isConfirmationDialogAllowed
- true if the component is allowed to ask confirmation to the user, false otherwise.
public boolean print(boolean isShowingDialog)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |