public class BrowserComponent extends Container
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP
Constructor and Description |
---|
BrowserComponent()
This constructor will work as expected when a browser component is supported, see isNativeBrowserSupported()
|
Modifier and Type | Method and Description |
---|---|
void |
addWebEventListener(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 |
destroy()
Release native resources of this Browser Component
|
void |
execute(String javaScript)
Executes the given JavaScript string within the current context
|
String |
executeAndReturnString(String javaScript)
Executes the given JavaScript and returns a result string from the underlying platform
where applicable
|
void |
exposeInJavaScript(Object o,
String name)
Deprecated.
this doesn't work in most platforms see issue 459 for details, use the setBrowserNavigationCallback
method instead
|
void |
fireWebEvent(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
|
BrowserNavigationCallback |
getBrowserNavigationCallback()
The browser navigation callback interface allows handling a case where
a URL invocation can be delegated to Java code.
|
String |
getTitle()
The page title
|
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
|
boolean |
isNativeScrollingEnabled()
This method is unreliable and is only here for consistency with setNativeScrollingEnabled.
|
boolean |
isPinchToZoomEnabled()
This method is unreliable and is only here for consistency with setPinchToZoomEnabled,
it will not return whether the platform supports pinch since this is very hard to detect
properly.
|
void |
reload()
Reload the current page
|
void |
removeWebEventListener(String type,
ActionListener listener)
Removes the listener, see addWebEventListener for details
|
void |
setBrowserNavigationCallback(BrowserNavigationCallback callback)
Set the browser navigation callback which allows handling a case where
a URL invocation can be delegated to Java code.
|
void |
setNativeScrollingEnabled(boolean b)
This flag allows disabling the native browser scrolling on platforms that support it
|
void |
setPage(String html,
String baseUrl)
Shows the given HTML in the native viewer
|
void |
setPinchToZoomEnabled(boolean e)
Some platforms require that you enable pinch to zoom explicitly.
|
void |
setProperty(String key,
Object value)
This method allows customizing the properties of a web view in various ways including platform specific settings.
|
void |
setURL(String url)
Sets the page URL, jar: URL's must be supported by the implementation
|
void |
stop()
Cancel the loading of the current page
|
addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize, cancelRepaints, clearClientProperties, contains, createAnimateMotion, dragInitiated, drop, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY, isSelectableInteraction, keyPressed, keyReleased, layoutContainer, morph, morphAndWait, paint, paintComponentBackground, paintGlass, paramString, pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager
addDragOverListener, addDropListener, addFocusListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, animate, bindProperty, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus, initComponent, initCustomStyle, installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, removeDragOverListener, removeDropListener, removeFocusListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, repaint, repaint, requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, 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, setSameHeight, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged, toString, unbindProperty
public BrowserComponent()
public void setBrowserNavigationCallback(BrowserNavigationCallback callback)
callback
- the callback interfacepublic BrowserNavigationCallback getBrowserNavigationCallback()
public static boolean isNativeBrowserSupported()
public void setProperty(String key, Object value)
key
- see the documentation with the CodenameOne Implementation for further detailsvalue
- see the documentation with the CodenameOne Implementation for further detailspublic String getTitle()
public String getURL()
public void setURL(String url)
url
- the URLpublic void reload()
public boolean hasBack()
public boolean hasForward()
public void back()
public void forward()
public void clearHistory()
public void setPinchToZoomEnabled(boolean e)
e
- true to enable pinch to zoom, false to disable itpublic boolean isPinchToZoomEnabled()
public void setNativeScrollingEnabled(boolean b)
b
- true to enable native scrolling, notice that non-native scrolling might be problematicpublic boolean isNativeScrollingEnabled()
public void setPage(String html, String baseUrl)
html
- HTML web pagebaseUrl
- base URL to associate with the HTMLpublic void addWebEventListener(String type, ActionListener listener)
type
- platform specific but must support: onStart, onLoad, onErrorlistener
- callback for the eventpublic void removeWebEventListener(String type, ActionListener listener)
type
- see addWebEventListener for detailslistener
- see addWebEventListener for detailspublic void stop()
public void destroy()
public void fireWebEvent(String type, ActionEvent ev)
type
- the type of the eventev
- the eventpublic void execute(String javaScript)
javaScript
- the JavaScript stringpublic String executeAndReturnString(String javaScript)
javaScript
- the JavaScript code to executepublic void exposeInJavaScript(Object o, String name)
o
- the object to invoke, notice all public fields and methods would be exposed to JavaScriptname
- the name to expose within JavaScript