Class HtmlPanel
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,FrameContext
HtmlBlockPanel
internally, depending on whether the document is determined to be a FRAMESET
or not.
Invoke method setDocument(Document, HtmlRendererContext)
in order to
schedule a document for rendering.
- See Also:
-
Nested Class Summary
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
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds listener of selection changes.boolean
copy()
Copies the current selection, if any, into the clipboard.protected HtmlBlockPanel
createHtmlBlockPanel
(UserAgentContext ucontext, HtmlRendererContext rcontext) Method invoked internally to create aHtmlBlockPanel
.static HtmlPanel
createlocalPanel
(URLConnection connection, HtmlPanel panel, HtmlRendererContext rendererContext, HtmlRendererConfig config, String uri) void
delayedRelayout
(NodeImpl node) delayedRelayout.void
expandSelection
(RenderableSpot rpoint) expandSelection.Gets the root Renderable of the HTML block.Gets a DOM node enclosing the selection.Gets the selection text.boolean
Returns true only if the current block has a selection.void
Removes a listener of selection changes that was previously added.void
resetSelection
(RenderableSpot rpoint) resetSelection.void
scroll
(double x, double y) Scrolls the document such that x and y coordinates are placed in the upper-left corner of the panel.void
scrollBy
(double x, double y) scrollBy.void
If the current document is not a FRAMESET, this method scrolls the body area to the given location.void
Scrolls the body area to the node given, if it is part of the current document.void
scrollToElement
(String nameOrId) Scrolls to the element identified by the given ID in the current document.void
setDefaultOverflowX
(int overflow) Sets the default horizontal overflow.void
setDefaultOverflowY
(int overflow) Sets the default vertical overflow.void
setDocument
(Document node, HtmlRendererContext rcontext) Sets an HTML DOM node and invalidates the component so it is rendered as soon as possible in the GUI thread.void
setPreferredWidth
(int width) Sets a preferred width that serves as a hint in calculating the preferred size of the HtmlPanel.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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, updateUI
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, 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
htmlBlockPanel
-
-
Constructor Details
-
HtmlPanel
public HtmlPanel()Constructs an HtmlPanel.
-
-
Method Details
-
addSelectionChangeListener
Adds listener of selection changes. Note that it does not have any effect on FRAMESETs.- Parameters:
listener
- An instance ofSelectionChangeListener
.
-
copy
public boolean copy()Copies the current selection, if any, into the clipboard. This method has no effect in FRAMESETs at the moment.- Returns:
- a boolean.
-
createHtmlBlockPanel
protected HtmlBlockPanel createHtmlBlockPanel(UserAgentContext ucontext, HtmlRendererContext rcontext) Method invoked internally to create aHtmlBlockPanel
. It is made available so it can be overridden.- Parameters:
ucontext
- aUserAgentContext
object.rcontext
- aHtmlRendererContext
object.- Returns:
- a
HtmlBlockPanel
object.
-
delayedRelayout
delayedRelayout.
Invalidates the layout of the given node and schedules it to be layed out later. Multiple invalidations may be processed in a single document layout.- Specified by:
delayedRelayout
in interfaceFrameContext
- Parameters:
node
- aNodeImpl
object.
-
expandSelection
expandSelection.
Internal method used to expand the selection to the given point.Note: This method should be invoked in the GUI thread.
- Specified by:
expandSelection
in interfaceFrameContext
- Parameters:
rpoint
- aRenderableSpot
object.
-
getBlockRenderable
Gets the root Renderable of the HTML block. It returns null for FRAMESETs.- Returns:
- a
BoundableRenderable
object.
-
getSelectionNode
Gets a DOM node enclosing the selection. The node returned should be the inner-most node that encloses both selection start and end points. Note that the selection end point may be just outside of the selection.Note: This method should be invoked in the GUI thread.
- Returns:
- A node enclosing the current selection, or null if there is no such node. It also returns null for FRAMESETs.
-
getSelectionText
Gets the selection text.Note: This method should be invoked in the GUI thread.
- Returns:
- a
String
object.
-
hasSelection
public boolean hasSelection()Returns true only if the current block has a selection. This method has no effect in FRAMESETs at the moment.- Returns:
- a boolean.
-
removeSelectionChangeListener
Removes a listener of selection changes that was previously added.- Parameters:
listener
- aSelectionChangeListener
object.
-
resetSelection
resetSelection.
Internal method used to reset the selection so that it is empty at the given point. This is what is called when the user clicks on a point in the document.Note: This method should be invoked in the GUI thread.
- Specified by:
resetSelection
in interfaceFrameContext
- Parameters:
rpoint
- aRenderableSpot
object.
-
scroll
public void scroll(double x, double y) Scrolls the document such that x and y coordinates are placed in the upper-left corner of the panel.This method may be called outside of the GUI Thread.
- Parameters:
x
- The x coordinate.y
- The y coordinate.
-
scrollBy
public void scrollBy(double x, double y) scrollBy.
-
scrollTo
Scrolls the body area to the node given, if it is part of the current document.This method should be called from the GUI thread.
- Parameters:
node
- A DOM node.
-
scrollTo
If the current document is not a FRAMESET, this method scrolls the body area to the given location.This method should be called from the GUI thread.
- Parameters:
bounds
- The bounds in the scrollable block area that should become visible.xIfNeeded
- If this parameter is true, scrolling will only occur if the requested bounds are not currently visible horizontally.yIfNeeded
- If this parameter is true, scrolling will only occur if the requested bounds are not currently visible vertically.
-
scrollToElement
Scrolls to the element identified by the given ID in the current document.If this method is invoked outside the GUI thread, the operation is scheduled to be performed as soon as possible in the GUI thread.
- Parameters:
nameOrId
- The name or ID of the element in the document.
-
setDefaultOverflowX
public void setDefaultOverflowX(int overflow) Sets the default horizontal overflow.This method has no effect on FRAMESETs.
- Parameters:
overflow
- SeeRenderState
.
-
setDefaultOverflowY
public void setDefaultOverflowY(int overflow) Sets the default vertical overflow.This method has no effect on FRAMESETs.
- Parameters:
overflow
- SeeRenderState
.
-
createlocalPanel
public static HtmlPanel createlocalPanel(URLConnection connection, HtmlPanel panel, HtmlRendererContext rendererContext, HtmlRendererConfig config, String uri) throws Exception - Throws:
Exception
-
setDocument
Sets an HTML DOM node and invalidates the component so it is rendered as soon as possible in the GUI thread.If this method is called from a thread that is not the GUI dispatch thread, the document is scheduled to be set later. Note that
preferred size
calculations should be done in the GUI dispatch thread for this reason.- Parameters:
node
- This should normally be a Document instance obtained withDocumentBuilderImpl
.rcontext
- A renderer context.- See Also:
-
setPreferredWidth
public void setPreferredWidth(int width) Sets a preferred width that serves as a hint in calculating the preferred size of the HtmlPanel. Note that the preferred size can only be calculated when a document is available, and it will vary during incremental rendering.This method currently does not have any effect when the document is a FRAMESET.
Note also that setting the preferred width (to a value other than -1) will negatively impact performance.
- Parameters:
width
- The preferred width, or -1 to unset.
-