public class HTMLPane
extends javax.swing.JTextPane
TryHTMLPane testPane = new TryHTMLPane();
final JFrame f = new JFrame();
JScrollPane scroller = new JScrollPane(testPane,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
);
f.add(scroller);
The relationships of the HTMLxxxx objects is
Modifier and Type | Class and Description |
---|---|
static class |
HTMLPane.ChoiceDiv |
static class |
HTMLPane.ChoiceGroup
A document may be displayed piecemeal; nominally each piece
corresponds to a tab in the view, but other organizations
will also be used.
|
javax.swing.JEditorPane.AccessibleJEditorPane, javax.swing.JEditorPane.AccessibleJEditorPaneHTML, javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.DropLocation, javax.swing.text.JTextComponent.KeyBinding
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
HIDDEN |
static java.lang.String |
HTMLPLUS |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
HTMLPane()
Create an empty HTMLPane.
|
Modifier and Type | Method and Description |
---|---|
static HTMLPane |
create(java.lang.String html,
HTMLPage.EmbedListener embedEar)
Produce an HTMLPane viewing a String.An EmbedListener may be supplied
to process embedded elements.
|
void |
dumpElementTree(javax.swing.text.Element elt,
java.lang.String indent)
Dump an element and children to stdout.
|
void |
dumpElementTree(javax.swing.text.Element elt,
java.lang.String indent,
java.lang.String fileName)
Dump an element and children to a named file.
|
static void |
dumpHTML(java.lang.String fileName,
javax.swing.text.Element elt) |
static void |
dumpViews(Writer f,
javax.swing.text.View v,
java.lang.String indent)
Write a view tree to a Writer.
|
static void |
dumpViewTree(java.lang.String fileName,
javax.swing.text.View v)
Write view tree to to file.
|
static void |
dumpViewTree(javax.swing.text.View v)
Write view tree to stdout
|
java.awt.Dimension |
getPreferredSize() |
boolean |
getScrollableTracksViewportWidth() |
java.lang.String |
getToolTipText(java.awt.event.MouseEvent evt)
Change title attributes into tooltips.
|
boolean |
loadDocument(java.lang.Class<?> aClass,
java.lang.String locator)
Shortcut for loadDocument with a third argument of null.
|
boolean |
loadDocument(java.lang.Class<?> aClass,
java.lang.String locator,
java.net.URL base)
Load the document of the given JEditorPane from a webpage at
a given locator (ala IOUtils.getInputStream).
|
boolean |
loadDocument(java.lang.String locator)
Load the document from a webpage at a given locator (ala
IOUtils.getInputStream).
|
void |
loadDocumentFromStream(InputStream src)
Load an HTML document from an InputStream.
|
void |
loadDocumentFromString(java.lang.String s) |
void |
setPreferredSize(java.awt.Dimension d) |
addStyle, createDefaultEditorKit, getCharacterAttributes, getInputAttributes, getLogicalStyle, getParagraphAttributes, getStyle, getStyledDocument, getStyledEditorKit, getUIClassID, insertComponent, insertIcon, paramString, removeStyle, replaceSelection, setCharacterAttributes, setDocument, setEditorKit, setLogicalStyle, setParagraphAttributes, setStyledDocument
addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getScrollableTracksViewportHeight, getStream, getText, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, scrollToReference, setContentType, setEditorKitForContentType, setPage, setPage, setText
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, 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, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String HTMLPLUS
public static final java.lang.String HIDDEN
public HTMLPane()
public boolean loadDocument(java.lang.String locator)
locator
- a locator identifying the document to be loadedpublic boolean loadDocument(java.lang.Class<?> aClass, java.lang.String locator)
aClass
- the Class for the application; its ClassLoader
will be applied to resolve "resource:" and "jardir:" locators.locator
- name of the document to be loaded (ala
IOUtils.getInputStream).public boolean loadDocument(java.lang.Class<?> aClass, java.lang.String locator, java.net.URL base)
aClass
- the Class for the application; its ClassLoader
will be applied to resolve "resource:" and "jardir:" locators.locator
- name of the document to be loaded (ala
IOUtils.getInputStream).base
- base URL for resolving relative references in the document.
This value will be overridden if the document has a <base> element.public void loadDocumentFromStream(InputStream src) throws IOException
src
- the document source text.IOException
- if reading fails
TODO switch to HTMLEditorKit.read. It can read strings and read incrementally.public void loadDocumentFromString(java.lang.String s) throws IOException
IOException
public static HTMLPane create(java.lang.String html, HTMLPage.EmbedListener embedEar) throws IOException
html
- the html to display
reading the source and creating the contents of the pane.
This function may apply setWidthOfBody (below).embedEar
- an HTMLPage.EmbedListener to be applied
while reading the html into the page. May be null.IOException
- for IO errorpublic boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
getScrollableTracksViewportWidth
in class javax.swing.JEditorPane
public java.lang.String getToolTipText(java.awt.event.MouseEvent evt)
getToolTipText
in class javax.swing.text.JTextComponent
evt
- a mouse eventpublic void dumpElementTree(javax.swing.text.Element elt, java.lang.String indent) throws IOException, javax.swing.text.BadLocationException
elt
- the Element to dumpindent
- One instance of this is prepended
to a line for each level of nesting.IOException
- for errorjavax.swing.text.BadLocationException
- cannot happenpublic void dumpElementTree(javax.swing.text.Element elt, java.lang.String indent, java.lang.String fileName)
elt
- the Element to dumpindent
- line prefix one for each level of nestingfileName
- where to write the outputpublic static void dumpHTML(java.lang.String fileName, javax.swing.text.Element elt)
public static void dumpViewTree(java.lang.String fileName, javax.swing.text.View v)
fileName
- File namev
- top level view in the treepublic static void dumpViewTree(javax.swing.text.View v)
v
- top level view in the treepublic static void dumpViews(Writer f, javax.swing.text.View v, java.lang.String indent) throws IOException
f
- The destination.v
- The parent view.indent
- Prefix to lines. Three spaces are appended for each level of depth.IOException
- If writing to f throws and exceptionpublic java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JEditorPane
public void setPreferredSize(java.awt.Dimension d)
setPreferredSize
in class javax.swing.JComponent