public class HTMLComponent extends Container implements ActionListener
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
Constructor and Description |
---|
HTMLComponent(DocumentRequestHandler handler)
Constructs HTMLComponent
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent evt)
Invoked when an action occurred on a component
|
static void |
addCharEntitiesRange(String[] symbols,
int startcode)
Adds the given symbols array to the user defined char entities table with the startcode provided as the code of the first string, startcode+1 for the second etc.
|
static void |
addCharEntity(String symbol,
int code)
Adds the given symbol and code to the user defined char entities table.
|
static void |
addFont(String fontKey,
Font font)
Sets the given LWUIT font for use with HTMLComponents.
|
static void |
addSpecialKey(String specialKeyName,
int specialKeyCode)
Adds support for a special key to be used as an accesskey.
|
boolean |
animate()
Allows the animation to reduce "repaint" calls when it returns false.
|
void |
cancel()
Cancels the loading of the current page
|
protected void |
deinitialize()
If the component is taken off for any reason, makes sure access keys are not active
|
DocumentInfo |
getDocumentInfo()
Returns the DocumentInfo that currently represents the document loaded/shown
|
HTMLCallback |
getHTMLCallback()
Returns the HTMLCallback that is set on this HTMLComponent
|
int |
getPageStatus()
Returns the page status
|
String |
getPageURL()
Returns the page's URL
|
DocumentRequestHandler |
getRequestHandler()
Returns the document request handler
|
String |
getTitle()
Returns the HTML page's title as described in its TITLE tag
|
protected void |
initComponent()
Overrides initComponent to add the key listeners to the access keys when the component is first added to the form/displayed
This is useful when the component is added only after the page was read
|
void |
layoutContainer()
Performs the layout of the container if a layout is necessary
|
void |
scrollPages(int pages,
boolean animate)
Scrolls the HTMLComponent several pages forward/backward.
|
void |
scrollPixels(int pixels,
boolean animate)
Scrolls the HTMLComponent several pixels forward/backward.
|
void |
setBodyText(String htmlText)
Sets the given string containing HTML code as this HTMLComponent's body
|
boolean |
setBodyText(String htmlText,
String encoding)
Sets the given string containing HTML code as this HTMLComponent's body.
|
static void |
setCSSSupportedMediaTypes(String[] supportedMediaTypes)
Sets the supported CSS media types to the given strings.
|
void |
setDefaultFont(String fontKey,
Font font)
Sets the default font for this HTMLComponent
|
boolean |
setHTML(String htmlText,
String encoding,
String title,
boolean isFullHTML)
Sets the given string containing HTML code either as this HTMLComponent's body or as the full HTML.
|
void |
setHTMLCallback(HTMLCallback callback)
Sets an HTMLCallback to listen to this HTMLCOmponent
|
void |
setIgnoreCSS(boolean ignore)
Sets whether this HTMLComponent will ignore all CSS.directives.
|
static void |
setMaxThreads(int threadsNum)
Sets the maximum number of threads to use for image download
|
void |
setPage(String pageURL)
Sets this HTMLComponent to render the document in the specified URL
|
void |
setPageStyle(Style pageStyle)
Sets the style of the page, allowing for example to set transparency to the main page.
|
void |
setShowImages(boolean show)
Sets whether this HTMLComponent will download and show linked images or not
|
addComponent, addComponent, addComponent, addComponent, applyRTL, calcPreferredSize, contains, flushReplace, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getLayout, getLayoutHeight, getLayoutWidth, getScrollIncrement, invalidate, isScrollableX, isScrollableY, paint, paintGlass, paramString, pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer, setLayout, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout
addFocusListener, calcScrollSize, contains, deinitializeCustomStyle, dragInitiated, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getHeight, getLabelForComponent, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getScrollAnimationSpeed, getScrollDimension, getScrollX, getScrollY, getSelectCommandText, getSelectedStyle, getSideGap, getStyle, getUIID, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, handlesInput, hasFocus, initCustomStyle, isBorderPainted, isDragActivated, isEnabled, isFocusable, isFocusPainted, isInitialized, isRTL, isScrollable, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerDragged, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setBorderPainted, setDirtyRegion, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setLabelForComponent, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setRTL, setScrollAnimationSpeed, setScrollSize, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setStyle, setTactileTouch, setTensileDragEnabled, setUIID, setUnselectedStyle, setUnSelectedStyle, setVisible, setWidth, setX, setY, styleChanged, toString
public HTMLComponent(DocumentRequestHandler handler)
handler
- The HttpRequestHandler to which all requestes for links will be sentpublic static void addFont(String fontKey, Font font)
fontKey
- The font key in the format described abovefont
- The actual LWUIT font objectpublic static void addCharEntity(String symbol, int code)
symbol
- The symbol to addcode
- The symbol's codepublic static void addSpecialKey(String specialKeyName, int specialKeyCode)
specialKeyName
- The name of the special key as denoted in CSS filesspecialKeyCode
- The special key codepublic static void addCharEntitiesRange(String[] symbols, int startcode)
symbols
- The symbols to addstartcode
- The symbol's codepublic static void setMaxThreads(int threadsNum)
threadsNum
- the maximum number of threads to use for image downloadpublic static void setCSSSupportedMediaTypes(String[] supportedMediaTypes)
supportedMediaTypes
- A string array containing the media types that should be supportedpublic DocumentRequestHandler getRequestHandler()
public DocumentInfo getDocumentInfo()
public void setHTMLCallback(HTMLCallback callback)
callback
- The HTMLCallback that will receive eventspublic HTMLCallback getHTMLCallback()
public void setDefaultFont(String fontKey, Font font)
fontKey
- The font key in the format described in setFont (Can be null for default font, but it is recommended to add a descriptive key if this is a bitmap font to enable the font engine to use it in other cases as well)font
- The actual LWUIT font objectsetFont
public void setShowImages(boolean show)
show
- true to show images, false otherwisepublic void setIgnoreCSS(boolean ignore)
show
- true to ignore CSS directives, false otherwisepublic void scrollPixels(int pixels, boolean animate)
pixels
- The number of pixels to scroll (positive for forward and negative for backward)animate
- true to animate the scrolling, false otherwisepublic void scrollPages(int pages, boolean animate)
pages
- The number of pages to scroll (positive for forward and negative for backward)animate
- true to animate the scrolling, false otherwisepublic void setBodyText(String htmlText)
htmlText
- The HTML body to setpublic boolean setBodyText(String htmlText, String encoding)
htmlText
- The HTML body to setencoding
- The encoding to use when reading the HTML i.e. UTF8, ISO-8859-1 etc.public boolean setHTML(String htmlText, String encoding, String title, boolean isFullHTML)
htmlText
- The HTML to setencoding
- The encoding to use when reading the HTML i.e. UTF8, ISO-8859-1 etc.title
- The HTML title, or null if none (Used only when isFullHTML is false)isFullHTML
- true if this is a full HTML document (with html/body tags), false if this HTML should be used as the HTMLComponent's bodypublic void cancel()
public void setPage(String pageURL)
pageURL
- The URL containing the HTML documentpublic void setPageStyle(Style pageStyle)
pageStyle
- The style to set to the pagepublic boolean animate()
Animation
Display
class.public String getTitle()
public String getPageURL()
public int getPageStatus()
protected void initComponent()
initComponent
in class Component
protected void deinitialize()
deinitialize
in class Component
public void layoutContainer()
layoutContainer
in class Container
public void actionPerformed(ActionEvent evt)
actionPerformed
in interface ActionListener
evt
- event object describing the source of the action as well as
its trigger