Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## chrriis.dj.nativeswing.swtimpl.components
Class JWebBrowser

    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

All Implemented Interfaces:
  NSComponent, ImageObserver, MenuContainer, Serializable, Accessible

    public class JWebBrowser

extends NSPanelComponent

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.

Author:
  Christopher Deckers
See Also:
  Serialized Form

Nested Class Summary

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_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.
`void` | `executeJavascript(String javascript)` Execute some javascript.
`Object` | `executeJavascriptWithResult(String javascript)` Execute some javascript, and wait for the result coming from the return statements.
`static String` | `getCookie(String url, String name)` Get a cookie for a given URL and a given name.
`JMenu` | `getFileMenu()` Get the file menu, which allows to modify the items.
`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.
`JMenuBar` | `getMenuBar()` Get the menu bar, which allows to modify the items.
`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.
`void` | `navigateBack()` Invoke the web browser Back functionality.
`void` | `navigateForward()` Invoke the web browser Forward functionality.
`void` | `reloadPage()` Invoke the web browser Reload functionality.
`void` | `removeWebBrowserListener(WebBrowserListener listener)` Remove a web browser listener.
`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.
`void` | `stopLoading()` Invoke the web browser Stop functionality, to stop all current loading operations.
`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 javax.swing.JComponent
`addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

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`

Field Detail

### COMMAND_LOCATION_PREFIX

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

  See Also:
    Constant Field Values

### COMMAND_STATUS_PREFIX

    public static final String COMMAND_STATUS_PREFIX

  The prefix to use when sending a command from some web content, by setting window.status from Javascript.

  See Also:
    Constant Field Values

Constructor Detail

### JWebBrowser

    public JWebBrowser(NSOption... options)

  Construct a new web browser.

  Parameters:
    `options` - the options to configure the behavior of this component.

Method Detail

### useXULRunnerRuntime

    public static NSOption useXULRunnerRuntime()

  Create an option to make the web browser use the Mozilla XULRunner runtime.

  Returns:
    the option to use the XULRunner runtime.

### clearSessionCookies

    public static void clearSessionCookies()

  Clear all session cookies from all web browser instances.

### getCookie

    public static String getCookie(String url,
                                   String name)

  Get a cookie for a given URL and a given name.

  Returns:
    the cookie or null if it does not exist.

### setCookie

    public static void setCookie(String url,
                                 String value)

  Set a cookie for all web browser instances.

  Parameters:
    `url` - the url.
    `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`)

### copyAppearance

    public static void copyAppearance(JWebBrowser fromWebBrowser,
                                      JWebBrowser toWebBrowser)

  Copy the appearance, the visibility of the various bars, from one web browser to another.

  Parameters:
    `fromWebBrowser` - the web browser to copy the appearance from.
    `toWebBrowser` - the web browser to copy the appearance to.

### copyContent

    public static void copyContent(JWebBrowser fromWebBrowser,
                                   JWebBrowser toWebBrowser)

  Copy the content, whether a URL or its HTML content, from one web browser to another.

  Parameters:
    `fromWebBrowser` - the web browser to copy the content from.
    `toWebBrowser` - the web browser to copy the content to.

### setStatusBarVisible

    public void setStatusBarVisible(boolean isStatusBarVisible)

  Set whether the status bar is visible.

  Parameters:
    `isStatusBarVisible` - true if the status bar should be visible, false otherwise.

### isStatusBarVisible

    public boolean isStatusBarVisible()

  Indicate whether the status bar is visible.

  Returns:
    true if the status bar is visible.

### setMenuBarVisible

    public void setMenuBarVisible(boolean isMenuBarVisible)

  Set whether the menu bar is visible.

  Parameters:
    `isMenuBarVisible` - true if the menu bar should be visible, false otherwise.

### isMenuBarVisible

    public boolean isMenuBarVisible()

  Indicate whether the menu bar is visible.

  Returns:
    true if the menu bar is visible.

### setButtonBarVisible

    public void setButtonBarVisible(boolean isButtonBarVisible)

  Set whether the button bar is visible.

  Parameters:
    `isButtonBarVisible` - true if the button bar should be visible, false otherwise.

### isButtonBarVisible

    public boolean isButtonBarVisible()

  Indicate whether the button bar is visible.

  Returns:
    true if the button bar is visible.

### setLocationBarVisible

    public void setLocationBarVisible(boolean isLocationBarVisible)

  Set whether the location bar is visible.

  Parameters:
    `isLocationBarVisible` - true if the location bar should be visible, false otherwise.

### isLocationBarVisible

    public boolean isLocationBarVisible()

  Indicate whether the location bar is visible.

  Returns:
    true if the location bar is visible.

### getPageTitle

    public String getPageTitle()

  Get the title of the web page.

  Returns:
    the title of the page.

### getStatusText

    public String getStatusText()

  Get the status text.

  Returns:
    the status text.

### getHTMLContent

    public String getHTMLContent()

  Get the HTML content.

  Returns:
    the HTML content.

### setHTMLContent

    public boolean setHTMLContent(String html)

  Set the HTML content.

  Parameters:
    `html` - the HTML content.

### getResourceLocation

    public String getResourceLocation()

  Get the location of the resource currently displayed.

  Returns:
    the location.

### navigate

    public boolean navigate(String resourceLocation)

  Navigate to a resource, with its location specified as a URL or path.

  Parameters:
    `resourceLocation` - the URL or path.
  Returns:
    true if the navigation was successful.

### isBackNavigationEnabled

    public boolean isBackNavigationEnabled()

  Indicate if the web browser Back functionality is enabled.

  Returns:
    true if the web browser Back functionality is enabled.

### navigateBack

    public void navigateBack()

  Invoke the web browser Back functionality.

### isForwardNavigationEnabled

    public boolean isForwardNavigationEnabled()

  Indicate if the web browser Forward functionality is enabled.

  Returns:
    true if the web browser Forward functionality is enabled.

### navigateForward

    public void navigateForward()

  Invoke the web browser Forward functionality.

### reloadPage

    public void reloadPage()

  Invoke the web browser Reload functionality.

### stopLoading

    public void stopLoading()

  Invoke the web browser Stop functionality, to stop all current loading operations.

### isJavascriptEnabled

    public boolean isJavascriptEnabled()

  Indicate if Javascript will be allowed to run in pages subsequently viewed.

  Returns:
    true if Javascript is enabled.

### setJavascriptEnabled

    public void setJavascriptEnabled(boolean isJavascriptEnabled)

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

  Parameters:
    `isJavascriptEnabled` - true to enable Javascript, false otherwise.

### executeJavascript

    public void executeJavascript(String javascript)

  Execute some javascript.

  Parameters:
    `javascript` - the javascript to execute.

### executeJavascriptWithResult

    public Object executeJavascriptWithResult(String javascript)

  Execute some javascript, and wait for the result coming from the return statements.

  Parameters:
    `javascript` - the javascript to execute which must contain explicit return statements.
  Returns:
    the value, potentially a String, Number, Boolean.

### createJavascriptFunctionCall

    public static String createJavascriptFunctionCall(String functionName,
                                                      Object... args)

  Create the Javascript function call using the function name and Java objects as arguments. Note that it does not contain a semi-colon at the end of the statement, to allow call chaining.

  Parameters:
    `functionName` - the name of the Javascript funtion.
    `args` - the Java objects (String, number, boolean, or array) which will get converted to Javascript arguments.
  Returns:
    the function call, in the form "functionName(convArg1, convArg2, ...)".

### convertJavaObjectToJavascript

    public static String convertJavaObjectToJavascript(Object o)

  Convert a Java object to Javascript, to simplify the task of executing scripts. Conversion adds quotes around Strings (with Java escaping and Javascript unescaping around), add brackets to arrays, treats arrays of arrays, and can handle null values.

  Parameters:
    `o` - the object to convert, which can be a String, number, boolean, or array.

### getLoadingProgress

    public int getLoadingProgress()

  Get the loading progress, a value between 0 and 100, where 100 means it is fully loaded.

  Returns:
    a value between 0 and 100 indicating the current loading progress.

### addWebBrowserListener

    public void addWebBrowserListener(WebBrowserListener listener)

  Add a web browser listener.

  Parameters:
    `listener` - The web browser listener to add.

### removeWebBrowserListener

    public void removeWebBrowserListener(WebBrowserListener listener)

  Remove a web browser listener.

  Parameters:
    `listener` - the web browser listener to remove.

### getWebBrowserListeners

    public WebBrowserListener[] getWebBrowserListeners()

  Get the web browser listeners.

  Returns:
    the web browser listeners.

### setBarsVisible

    public void setBarsVisible(boolean areBarsVisible)

  Show or hide all the bars at once.

  Parameters:
    `areBarsVisible` - true to show all bars, false to hide them all.

### getMenuBar

    public JMenuBar getMenuBar()

  Get the menu bar, which allows to modify the items.

  Returns:
    the menu bar.

### getFileMenu

    public JMenu getFileMenu()

  Get the file menu, which allows to modify the items.

  Returns:
    the file menu.

### getWebBrowserWindow

    public JWebBrowserWindow getWebBrowserWindow()

  Get the web browser window if the web browser is contained in one.

  Returns:
    the web browser Window, or null.

### setDefaultPopupMenuRegistered

    public void setDefaultPopupMenuRegistered(boolean isDefaultPopupMenuRegistered)

  Set whether this component is able to detect a popup menu gesture to show its default popup menu.

  Parameters:
    `isDefaultPopupMenuRegistered` - true if the default popup menu is registered.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD