com.sun.lwuit
Class BrowserComponent

java.lang.Object
  extended by com.sun.lwuit.Component
      extended by com.sun.lwuit.Container
          extended by com.sun.lwuit.BrowserComponent
All Implemented Interfaces:
Animation, StyleListener

public class BrowserComponent
extends Container

The browser component is an interface to an embeddable native platform browser on platforms that support embedding the native browser in place, if you need wide compatibility and flexibility you should check out the HTMLComponent which provides a lightweight 100% cross platform web component. This component will only work on platforms that support embedding a native browser which exclude earlier versions of Blackberry devices and J2ME devices.
Its recommended that you place this component in a fixed position (none scrollable) on the screen without other focusable components to prevent confusion between focus authority and allow the component to scroll itself rather than LWUIT making that decision for it.


Field Summary
 
Fields inherited from class com.sun.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Constructor Summary
BrowserComponent()
          This constructor will work as expected when a browser component is supported, see isNativeBrowserSupported()
 
Method Summary
 void addWebEventListener(java.lang.String type, ActionListener listener)
          Adds a listener to the given event type name, event type names are platform specific but some must be fired for all platforms and will invoke the action listener when the appropriate event loads
 void back()
          Navigates back in the history
 void clearHistory()
          Clears navigation history
 void execute(java.lang.String javaScript)
          Executes the given JavaScript string within the current context
 void exposeInJavaScript(java.lang.Object o, java.lang.String name)
          Allows exposing the given object to JavaScript code so the JavaScript code can invoke methods and access fields on the given object.
 void fireWebEvent(java.lang.String type, ActionEvent ev)
          Used internally by the implementation to fire an event from the native browser widget
 void forward()
          Navigates forward in the history
 java.lang.String getTitle()
          The page title
 java.lang.String getURL()
          The page URL
 boolean hasBack()
          Indicates whether back is currently available
 boolean hasForward()
          Indicates whether forward is currently available
static boolean isNativeBrowserSupported()
          Returns true if the platform supports embedding a native browser component
 void reload()
          Reload the current page
 void removeWebEventListener(java.lang.String type, ActionListener listener)
          Removes the listener, see addWebEventListener for details
 void setPage(java.lang.String html, java.lang.String baseUrl)
          Shows the given HTML in the native viewer
 void setProperty(java.lang.String key, java.lang.Object value)
          This method allows customizing the properties of a web view in various ways including platform specific settings.
 void setURL(java.lang.String url)
          Sets the page URL, jar: URL's must be supported by the implementation
 
Methods inherited from class com.sun.lwuit.Container
addComponent, addComponent, addComponent, addComponent, animateLayout, animateLayoutAndWait, applyRTL, calcPreferredSize, contains, dragInitiated, drop, findFirstFocusable, flushReplace, getBottomGap, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getScrollIncrement, getSideGap, invalidate, isEnabled, isScrollableX, isScrollableY, keyPressed, keyReleased, layoutContainer, paint, paintBackground, paintGlass, paramString, pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout
 
Methods inherited from class com.sun.lwuit.Component
addFocusListener, animate, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, drawDraggedImage, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getDisabledStyle, getDragImage, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypes, getPropertyValue, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle, getWidth, getVisibleBounds, getX, getY, growShrink, handlesInput, hasFocus, initComponent, initCustomStyle, installDefaultPainter, isAlwaysTensile, isDragActivated, isDragAndDropOperation, isDraggable, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInitialized, isRTL, isScrollable, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isSnapToGrid, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setPropertyValue, setRTL, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setWidth, setVisible, setX, setY, styleChanged, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BrowserComponent

public BrowserComponent()
This constructor will work as expected when a browser component is supported, see isNativeBrowserSupported()

Method Detail

isNativeBrowserSupported

public static boolean isNativeBrowserSupported()
Returns true if the platform supports embedding a native browser component

Returns:
true if native browsing is supported

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object value)
This method allows customizing the properties of a web view in various ways including platform specific settings. When a property isn't supported by a specific platform it is just ignored.

Parameters:
key - see the documentation with the LWUIT Implementation for further details
value - see the documentation with the LWUIT Implementation for further details

getTitle

public java.lang.String getTitle()
The page title

Returns:
the title

getURL

public java.lang.String getURL()
The page URL

Returns:
the URL

setURL

public void setURL(java.lang.String url)
Sets the page URL, jar: URL's must be supported by the implementation

Parameters:
url - the URL

reload

public void reload()
Reload the current page


hasBack

public boolean hasBack()
Indicates whether back is currently available

Returns:
true if back should work

hasForward

public boolean hasForward()
Indicates whether forward is currently available

Returns:
true if forward should work

back

public void back()
Navigates back in the history


forward

public void forward()
Navigates forward in the history


clearHistory

public void clearHistory()
Clears navigation history


setPage

public void setPage(java.lang.String html,
                    java.lang.String baseUrl)
Shows the given HTML in the native viewer

Parameters:
html - HTML web page
baseUrl - base URL to associate with the HTML

addWebEventListener

public void addWebEventListener(java.lang.String type,
                                ActionListener listener)
Adds a listener to the given event type name, event type names are platform specific but some must be fired for all platforms and will invoke the action listener when the appropriate event loads

Parameters:
type - platform specific but must support: onLoad, onError
listener - callback for the event

removeWebEventListener

public void removeWebEventListener(java.lang.String type,
                                   ActionListener listener)
Removes the listener, see addWebEventListener for details

Parameters:
type - see addWebEventListener for details
listener - see addWebEventListener for details

fireWebEvent

public void fireWebEvent(java.lang.String type,
                         ActionEvent ev)
Used internally by the implementation to fire an event from the native browser widget

Parameters:
type - the type of the event
ev - the event

execute

public void execute(java.lang.String javaScript)
Executes the given JavaScript string within the current context

Parameters:
javaScript - the JavaScript string

exposeInJavaScript

public void exposeInJavaScript(java.lang.Object o,
                               java.lang.String name)
Allows exposing the given object to JavaScript code so the JavaScript code can invoke methods and access fields on the given object. Notice that on RIM devices which don't support reflection this object must implement the propriatery Scriptable interface http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/script/Scriptable.html

Parameters:
o - the object to invoke, notice all public fields and methods would be exposed to JavaScript
name - the name to expose within JavaScript