javax.swing.text.html
Class HTMLDocument

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.text.AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument 
      extended by javax.swing.text.DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument 
          extended by javax.swing.text.html.HTMLDocument
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document , StyledDocument sample code for javax.swing.text.StyledDocument definition code for javax.swing.text.StyledDocument

public class HTMLDocument
extends DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument

A document that models HTML. The purpose of this model is to support both browsing and editing. As a result, the structure described by an HTML document is not exactly replicated by default. The element structure that is modeled by default, is built by the class HTMLDocument.HTMLReader, which implements the HTMLEditorKit.ParserCallback protocol that the parser expects. To change the structure one can subclass HTMLReader, and reimplement the method getReader(int) sample code for javax.swing.text.html.HTMLDocument.getReader(int) definition code for javax.swing.text.html.HTMLDocument.getReader(int) to return the new reader implementation. The documentation for HTMLReader should be consulted for the details of the default structure created. The intent is that the document be non-lossy (although reproducing the HTML format may result in a different format).

The document models only HTML, and makes no attempt to store view attributes in it. The elements are identified by the StyleContext.NameAttribute attribute, which should always have a value of type HTML.Tag that identifies the kind of element. Some of the elements (such as comments) are synthesized. The HTMLFactory uses this attribute to determine what kind of view to build.

This document supports incremental loading. The TokenThreshold property controls how much of the parse is buffered before trying to update the element structure of the document. This property is set by the EditorKit so that subclasses can disable it.

The Base property determines the URL against which relative URLs are resolved. By default, this will be the Document.StreamDescriptionProperty if the value of the property is a URL. If a <BASE> tag is encountered, the base will become the URL specified by that tag. Because the base URL is a property, it can of course be set directly.

The default content storage mechanism for this document is a gap buffer (GapContent). Alternatives can be supplied by using the constructor that takes a Content implementation.

See Also:
Serialized Form

Nested Class Summary
 class HTMLDocument.BlockElement sample code for javax.swing.text.html.HTMLDocument.BlockElement definition code for javax.swing.text.html.HTMLDocument.BlockElement
          An element that represents a structural block of HTML.
 class HTMLDocument.HTMLReader sample code for javax.swing.text.html.HTMLDocument.HTMLReader definition code for javax.swing.text.html.HTMLDocument.HTMLReader
          An HTML reader to load an HTML document with an HTML element structure.
static class HTMLDocument.Iterator sample code for javax.swing.text.html.HTMLDocument.Iterator definition code for javax.swing.text.html.HTMLDocument.Iterator
          An iterator to iterate over a particular type of tag.
 class HTMLDocument.RunElement sample code for javax.swing.text.html.HTMLDocument.RunElement definition code for javax.swing.text.html.HTMLDocument.RunElement
          An element that represents a chunk of text that has a set of HTML character level attributes assigned to it.
 
Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument
DefaultStyledDocument.AttributeUndoableEdit sample code for javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit definition code for javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit , DefaultStyledDocument.ElementBuffer sample code for javax.swing.text.DefaultStyledDocument.ElementBuffer definition code for javax.swing.text.DefaultStyledDocument.ElementBuffer , DefaultStyledDocument.ElementSpec sample code for javax.swing.text.DefaultStyledDocument.ElementSpec definition code for javax.swing.text.DefaultStyledDocument.ElementSpec , DefaultStyledDocument.SectionElement sample code for javax.swing.text.DefaultStyledDocument.SectionElement definition code for javax.swing.text.DefaultStyledDocument.SectionElement
 
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement sample code for javax.swing.text.AbstractDocument.AbstractElement definition code for javax.swing.text.AbstractDocument.AbstractElement , AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext , AbstractDocument.BranchElement sample code for javax.swing.text.AbstractDocument.BranchElement definition code for javax.swing.text.AbstractDocument.BranchElement , AbstractDocument.Content sample code for javax.swing.text.AbstractDocument.Content definition code for javax.swing.text.AbstractDocument.Content , AbstractDocument.DefaultDocumentEvent sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent , AbstractDocument.ElementEdit sample code for javax.swing.text.AbstractDocument.ElementEdit definition code for javax.swing.text.AbstractDocument.ElementEdit , AbstractDocument.LeafElement sample code for javax.swing.text.AbstractDocument.LeafElement definition code for javax.swing.text.AbstractDocument.LeafElement
 
Field Summary
static String sample code for java.lang.String definition code for java.lang.String AdditionalComments sample code for javax.swing.text.html.HTMLDocument.AdditionalComments definition code for javax.swing.text.html.HTMLDocument.AdditionalComments
          Document property key value.
 
Fields inherited from class javax.swing.text.DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument
buffer sample code for javax.swing.text.DefaultStyledDocument.buffer definition code for javax.swing.text.DefaultStyledDocument.buffer , BUFFER_SIZE_DEFAULT sample code for javax.swing.text.DefaultStyledDocument.BUFFER_SIZE_DEFAULT definition code for javax.swing.text.DefaultStyledDocument.BUFFER_SIZE_DEFAULT
 
Fields inherited from class javax.swing.text.AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument
BAD_LOCATION sample code for javax.swing.text.AbstractDocument.BAD_LOCATION definition code for javax.swing.text.AbstractDocument.BAD_LOCATION , BidiElementName sample code for javax.swing.text.AbstractDocument.BidiElementName definition code for javax.swing.text.AbstractDocument.BidiElementName , ContentElementName sample code for javax.swing.text.AbstractDocument.ContentElementName definition code for javax.swing.text.AbstractDocument.ContentElementName , ElementNameAttribute sample code for javax.swing.text.AbstractDocument.ElementNameAttribute definition code for javax.swing.text.AbstractDocument.ElementNameAttribute , listenerList sample code for javax.swing.text.AbstractDocument.listenerList definition code for javax.swing.text.AbstractDocument.listenerList , ParagraphElementName sample code for javax.swing.text.AbstractDocument.ParagraphElementName definition code for javax.swing.text.AbstractDocument.ParagraphElementName , SectionElementName sample code for javax.swing.text.AbstractDocument.SectionElementName definition code for javax.swing.text.AbstractDocument.SectionElementName
 
Fields inherited from interface javax.swing.text.Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document
StreamDescriptionProperty sample code for javax.swing.text.Document.StreamDescriptionProperty definition code for javax.swing.text.Document.StreamDescriptionProperty , TitleProperty sample code for javax.swing.text.Document.TitleProperty definition code for javax.swing.text.Document.TitleProperty
 
Constructor Summary
HTMLDocument sample code for javax.swing.text.html.HTMLDocument.HTMLDocument() definition code for javax.swing.text.html.HTMLDocument.HTMLDocument() ()
          Constructs an HTML document using the default buffer size and a default StyleSheet.
HTMLDocument sample code for javax.swing.text.html.HTMLDocument.HTMLDocument(javax.swing.text.AbstractDocument.Content, javax.swing.text.html.StyleSheet) definition code for javax.swing.text.html.HTMLDocument.HTMLDocument(javax.swing.text.AbstractDocument.Content, javax.swing.text.html.StyleSheet) (AbstractDocument.Content sample code for javax.swing.text.AbstractDocument.Content definition code for javax.swing.text.AbstractDocument.Content  c, StyleSheet sample code for javax.swing.text.html.StyleSheet definition code for javax.swing.text.html.StyleSheet  styles)
          Constructs an HTML document with the given content storage implementation and the given style/attribute storage mechanism.
HTMLDocument sample code for javax.swing.text.html.HTMLDocument.HTMLDocument(javax.swing.text.html.StyleSheet) definition code for javax.swing.text.html.HTMLDocument.HTMLDocument(javax.swing.text.html.StyleSheet) (StyleSheet sample code for javax.swing.text.html.StyleSheet definition code for javax.swing.text.html.StyleSheet  styles)
          Constructs an HTML document with the default content storage implementation and the specified style/attribute storage mechanism.
 
Method Summary
protected  void create sample code for javax.swing.text.html.HTMLDocument.create(javax.swing.text.DefaultStyledDocument.ElementSpec[]) definition code for javax.swing.text.html.HTMLDocument.create(javax.swing.text.DefaultStyledDocument.ElementSpec[]) (DefaultStyledDocument.ElementSpec sample code for javax.swing.text.DefaultStyledDocument.ElementSpec definition code for javax.swing.text.DefaultStyledDocument.ElementSpec [] data)
          Replaces the contents of the document with the given element specifications.
protected  Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element createBranchElement sample code for javax.swing.text.html.HTMLDocument.createBranchElement(javax.swing.text.Element, javax.swing.text.AttributeSet) definition code for javax.swing.text.html.HTMLDocument.createBranchElement(javax.swing.text.Element, javax.swing.text.AttributeSet) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  parent, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
          Creates a document branch element, that can contain other elements.
protected  AbstractDocument.AbstractElement sample code for javax.swing.text.AbstractDocument.AbstractElement definition code for javax.swing.text.AbstractDocument.AbstractElement createDefaultRoot sample code for javax.swing.text.html.HTMLDocument.createDefaultRoot() definition code for javax.swing.text.html.HTMLDocument.createDefaultRoot() ()
          Creates the root element to be used to represent the default document structure.
protected  Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element createLeafElement sample code for javax.swing.text.html.HTMLDocument.createLeafElement(javax.swing.text.Element, javax.swing.text.AttributeSet, int, int) definition code for javax.swing.text.html.HTMLDocument.createLeafElement(javax.swing.text.Element, javax.swing.text.AttributeSet, int, int) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  parent, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a, int p0, int p1)
          Creates a document leaf element that directly represents text (doesn't have any children).
protected  void fireChangedUpdate sample code for javax.swing.text.html.HTMLDocument.fireChangedUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.text.html.HTMLDocument.fireChangedUpdate(javax.swing.event.DocumentEvent) (DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent  e)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireUndoableEditUpdate sample code for javax.swing.text.html.HTMLDocument.fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent) definition code for javax.swing.text.html.HTMLDocument.fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent) (UndoableEditEvent sample code for javax.swing.event.UndoableEditEvent definition code for javax.swing.event.UndoableEditEvent  e)
          Notifies all listeners that have registered interest for notification on this event type.
 URL sample code for java.net.URL definition code for java.net.URL getBase sample code for javax.swing.text.html.HTMLDocument.getBase() definition code for javax.swing.text.html.HTMLDocument.getBase() ()
          Returns the location to resolve relative URLs against.
 Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element getElement sample code for javax.swing.text.html.HTMLDocument.getElement(javax.swing.text.Element, java.lang.Object, java.lang.Object) definition code for javax.swing.text.html.HTMLDocument.getElement(javax.swing.text.Element, java.lang.Object, java.lang.Object) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  e, Object sample code for java.lang.Object definition code for java.lang.Object  attribute, Object sample code for java.lang.Object definition code for java.lang.Object  value)
          Returns the child element of e that contains the attribute, attribute with value value, or null if one isn't found.
 Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element getElement sample code for javax.swing.text.html.HTMLDocument.getElement(java.lang.String) definition code for javax.swing.text.html.HTMLDocument.getElement(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  id)
          Returns the element that has the given id Attribute.
 HTMLDocument.Iterator sample code for javax.swing.text.html.HTMLDocument.Iterator definition code for javax.swing.text.html.HTMLDocument.Iterator getIterator sample code for javax.swing.text.html.HTMLDocument.getIterator(javax.swing.text.html.HTML.Tag) definition code for javax.swing.text.html.HTMLDocument.getIterator(javax.swing.text.html.HTML.Tag) (HTML.Tag sample code for javax.swing.text.html.HTML.Tag definition code for javax.swing.text.html.HTML.Tag  t)
          Fetches an iterator for the specified HTML tag.
 HTMLEditorKit.Parser sample code for javax.swing.text.html.HTMLEditorKit.Parser definition code for javax.swing.text.html.HTMLEditorKit.Parser getParser sample code for javax.swing.text.html.HTMLDocument.getParser() definition code for javax.swing.text.html.HTMLDocument.getParser() ()
          Returns the parser that is used when inserting HTML into the existing document.
 boolean getPreservesUnknownTags sample code for javax.swing.text.html.HTMLDocument.getPreservesUnknownTags() definition code for javax.swing.text.html.HTMLDocument.getPreservesUnknownTags() ()
          Returns the behavior the parser observes when encountering unknown tags.
 HTMLEditorKit.ParserCallback sample code for javax.swing.text.html.HTMLEditorKit.ParserCallback definition code for javax.swing.text.html.HTMLEditorKit.ParserCallback getReader sample code for javax.swing.text.html.HTMLDocument.getReader(int) definition code for javax.swing.text.html.HTMLDocument.getReader(int) (int pos)
          Fetches the reader for the parser to use when loading the document with HTML.
 HTMLEditorKit.ParserCallback sample code for javax.swing.text.html.HTMLEditorKit.ParserCallback definition code for javax.swing.text.html.HTMLEditorKit.ParserCallback getReader sample code for javax.swing.text.html.HTMLDocument.getReader(int, int, int, javax.swing.text.html.HTML.Tag) definition code for javax.swing.text.html.HTMLDocument.getReader(int, int, int, javax.swing.text.html.HTML.Tag) (int pos, int popDepth, int pushDepth, HTML.Tag sample code for javax.swing.text.html.HTML.Tag definition code for javax.swing.text.html.HTML.Tag  insertTag)
          Returns the reader for the parser to use to load the document with HTML.
 StyleSheet sample code for javax.swing.text.html.StyleSheet definition code for javax.swing.text.html.StyleSheet getStyleSheet sample code for javax.swing.text.html.HTMLDocument.getStyleSheet() definition code for javax.swing.text.html.HTMLDocument.getStyleSheet() ()
          Fetches the StyleSheet with the document-specific display rules (CSS) that were specified in the HTML document itself.
 int getTokenThreshold sample code for javax.swing.text.html.HTMLDocument.getTokenThreshold() definition code for javax.swing.text.html.HTMLDocument.getTokenThreshold() ()
          Gets the number of tokens to buffer before trying to update the documents element structure.
protected  void insert sample code for javax.swing.text.html.HTMLDocument.insert(int, javax.swing.text.DefaultStyledDocument.ElementSpec[]) definition code for javax.swing.text.html.HTMLDocument.insert(int, javax.swing.text.DefaultStyledDocument.ElementSpec[]) (int offset, DefaultStyledDocument.ElementSpec sample code for javax.swing.text.DefaultStyledDocument.ElementSpec definition code for javax.swing.text.DefaultStyledDocument.ElementSpec [] data)
          Inserts new elements in bulk.
 void insertAfterEnd sample code for javax.swing.text.html.HTMLDocument.insertAfterEnd(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.insertAfterEnd(javax.swing.text.Element, java.lang.String) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem, String sample code for java.lang.String definition code for java.lang.String  htmlText)
          Inserts the HTML specified as a string after the the end of the given element.
 void insertAfterStart sample code for javax.swing.text.html.HTMLDocument.insertAfterStart(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.insertAfterStart(javax.swing.text.Element, java.lang.String) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem, String sample code for java.lang.String definition code for java.lang.String  htmlText)
          Inserts the HTML specified as a string at the start of the element.
 void insertBeforeEnd sample code for javax.swing.text.html.HTMLDocument.insertBeforeEnd(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.insertBeforeEnd(javax.swing.text.Element, java.lang.String) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem, String sample code for java.lang.String definition code for java.lang.String  htmlText)
          Inserts the HTML specified as a string at the end of the element.
 void insertBeforeStart sample code for javax.swing.text.html.HTMLDocument.insertBeforeStart(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.insertBeforeStart(javax.swing.text.Element, java.lang.String) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem, String sample code for java.lang.String definition code for java.lang.String  htmlText)
          Inserts the HTML specified as a string before the start of the given element.
protected  void insertUpdate sample code for javax.swing.text.html.HTMLDocument.insertUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AttributeSet) definition code for javax.swing.text.html.HTMLDocument.insertUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AttributeSet) (AbstractDocument.DefaultDocumentEvent sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent  chng, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
          Updates document structure as a result of text insertion.
 void processHTMLFrameHyperlinkEvent sample code for javax.swing.text.html.HTMLDocument.processHTMLFrameHyperlinkEvent(javax.swing.text.html.HTMLFrameHyperlinkEvent) definition code for javax.swing.text.html.HTMLDocument.processHTMLFrameHyperlinkEvent(javax.swing.text.html.HTMLFrameHyperlinkEvent) (HTMLFrameHyperlinkEvent sample code for javax.swing.text.html.HTMLFrameHyperlinkEvent definition code for javax.swing.text.html.HTMLFrameHyperlinkEvent  e)
          Processes HyperlinkEvents that are generated by documents in an HTML frame.
 void setBase sample code for javax.swing.text.html.HTMLDocument.setBase(java.net.URL) definition code for javax.swing.text.html.HTMLDocument.setBase(java.net.URL) (URL sample code for java.net.URL definition code for java.net.URL  u)
          Sets the location to resolve relative URLs against.
 void setInnerHTML sample code for javax.swing.text.html.HTMLDocument.setInnerHTML(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.setInnerHTML(javax.swing.text.Element, java.lang.String) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem, String sample code for java.lang.String definition code for java.lang.String  htmlText)
          Replaces the children of the given element with the contents specified as an HTML string.
 void setOuterHTML sample code for javax.swing.text.html.HTMLDocument.setOuterHTML(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.setOuterHTML(javax.swing.text.Element, java.lang.String) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem, String sample code for java.lang.String definition code for java.lang.String  htmlText)
          Replaces the given element in the parent with the contents specified as an HTML string.
 void setParagraphAttributes sample code for javax.swing.text.html.HTMLDocument.setParagraphAttributes(int, int, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.html.HTMLDocument.setParagraphAttributes(int, int, javax.swing.text.AttributeSet, boolean) (int offset, int length, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  s, boolean replace)
          Sets attributes for a paragraph.
 void setParser sample code for javax.swing.text.html.HTMLDocument.setParser(javax.swing.text.html.HTMLEditorKit.Parser) definition code for javax.swing.text.html.HTMLDocument.setParser(javax.swing.text.html.HTMLEditorKit.Parser) (HTMLEditorKit.Parser sample code for javax.swing.text.html.HTMLEditorKit.Parser definition code for javax.swing.text.html.HTMLEditorKit.Parser  parser)
          Sets the parser that is used by the methods that insert html into the existing document, such as setInnerHTML, and setOuterHTML.
 void setPreservesUnknownTags sample code for javax.swing.text.html.HTMLDocument.setPreservesUnknownTags(boolean) definition code for javax.swing.text.html.HTMLDocument.setPreservesUnknownTags(boolean) (boolean preservesTags)
          Determines how unknown tags are handled by the parser.
 void setTokenThreshold sample code for javax.swing.text.html.HTMLDocument.setTokenThreshold(int) definition code for javax.swing.text.html.HTMLDocument.setTokenThreshold(int) (int n)
          Sets the number of tokens to buffer before trying to update the documents element structure.
 
Methods inherited from class javax.swing.text.DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument
addDocumentListener sample code for javax.swing.text.DefaultStyledDocument.addDocumentListener(javax.swing.event.DocumentListener) definition code for javax.swing.text.DefaultStyledDocument.addDocumentListener(javax.swing.event.DocumentListener) , addStyle sample code for javax.swing.text.DefaultStyledDocument.addStyle(java.lang.String, javax.swing.text.Style) definition code for javax.swing.text.DefaultStyledDocument.addStyle(java.lang.String, javax.swing.text.Style) , getBackground sample code for javax.swing.text.DefaultStyledDocument.getBackground(javax.swing.text.AttributeSet) definition code for javax.swing.text.DefaultStyledDocument.getBackground(javax.swing.text.AttributeSet) , getCharacterElement sample code for javax.swing.text.DefaultStyledDocument.getCharacterElement(int) definition code for javax.swing.text.DefaultStyledDocument.getCharacterElement(int) , getDefaultRootElement sample code for javax.swing.text.DefaultStyledDocument.getDefaultRootElement() definition code for javax.swing.text.DefaultStyledDocument.getDefaultRootElement() , getFont sample code for javax.swing.text.DefaultStyledDocument.getFont(javax.swing.text.AttributeSet) definition code for javax.swing.text.DefaultStyledDocument.getFont(javax.swing.text.AttributeSet) , getForeground sample code for javax.swing.text.DefaultStyledDocument.getForeground(javax.swing.text.AttributeSet) definition code for javax.swing.text.DefaultStyledDocument.getForeground(javax.swing.text.AttributeSet) , getLogicalStyle sample code for javax.swing.text.DefaultStyledDocument.getLogicalStyle(int) definition code for javax.swing.text.DefaultStyledDocument.getLogicalStyle(int) , getParagraphElement sample code for javax.swing.text.DefaultStyledDocument.getParagraphElement(int) definition code for javax.swing.text.DefaultStyledDocument.getParagraphElement(int) , getStyle sample code for javax.swing.text.DefaultStyledDocument.getStyle(java.lang.String) definition code for javax.swing.text.DefaultStyledDocument.getStyle(java.lang.String) , getStyleNames sample code for javax.swing.text.DefaultStyledDocument.getStyleNames() definition code for javax.swing.text.DefaultStyledDocument.getStyleNames() , removeDocumentListener sample code for javax.swing.text.DefaultStyledDocument.removeDocumentListener(javax.swing.event.DocumentListener) definition code for javax.swing.text.DefaultStyledDocument.removeDocumentListener(javax.swing.event.DocumentListener) , removeStyle sample code for javax.swing.text.DefaultStyledDocument.removeStyle(java.lang.String) definition code for javax.swing.text.DefaultStyledDocument.removeStyle(java.lang.String) , removeUpdate sample code for javax.swing.text.DefaultStyledDocument.removeUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent) definition code for javax.swing.text.DefaultStyledDocument.removeUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent) , setCharacterAttributes sample code for javax.swing.text.DefaultStyledDocument.setCharacterAttributes(int, int, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.DefaultStyledDocument.setCharacterAttributes(int, int, javax.swing.text.AttributeSet, boolean) , setLogicalStyle sample code for javax.swing.text.DefaultStyledDocument.setLogicalStyle(int, javax.swing.text.Style) definition code for javax.swing.text.DefaultStyledDocument.setLogicalStyle(int, javax.swing.text.Style) , styleChanged sample code for javax.swing.text.DefaultStyledDocument.styleChanged(javax.swing.text.Style) definition code for javax.swing.text.DefaultStyledDocument.styleChanged(javax.swing.text.Style)
 
Methods inherited from class javax.swing.text.AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument
addUndoableEditListener sample code for javax.swing.text.AbstractDocument.addUndoableEditListener(javax.swing.event.UndoableEditListener) definition code for javax.swing.text.AbstractDocument.addUndoableEditListener(javax.swing.event.UndoableEditListener) , createPosition sample code for javax.swing.text.AbstractDocument.createPosition(int) definition code for javax.swing.text.AbstractDocument.createPosition(int) , dump sample code for javax.swing.text.AbstractDocument.dump(java.io.PrintStream) definition code for javax.swing.text.AbstractDocument.dump(java.io.PrintStream) , fireInsertUpdate sample code for javax.swing.text.AbstractDocument.fireInsertUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.text.AbstractDocument.fireInsertUpdate(javax.swing.event.DocumentEvent) , fireRemoveUpdate sample code for javax.swing.text.AbstractDocument.fireRemoveUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.text.AbstractDocument.fireRemoveUpdate(javax.swing.event.DocumentEvent) , getAsynchronousLoadPriority sample code for javax.swing.text.AbstractDocument.getAsynchronousLoadPriority() definition code for javax.swing.text.AbstractDocument.getAsynchronousLoadPriority() , getAttributeContext sample code for javax.swing.text.AbstractDocument.getAttributeContext() definition code for javax.swing.text.AbstractDocument.getAttributeContext() , getBidiRootElement sample code for javax.swing.text.AbstractDocument.getBidiRootElement() definition code for javax.swing.text.AbstractDocument.getBidiRootElement() , getContent sample code for javax.swing.text.AbstractDocument.getContent() definition code for javax.swing.text.AbstractDocument.getContent() , getCurrentWriter sample code for javax.swing.text.AbstractDocument.getCurrentWriter() definition code for javax.swing.text.AbstractDocument.getCurrentWriter() , getDocumentFilter sample code for javax.swing.text.AbstractDocument.getDocumentFilter() definition code for javax.swing.text.AbstractDocument.getDocumentFilter() , getDocumentListeners sample code for javax.swing.text.AbstractDocument.getDocumentListeners() definition code for javax.swing.text.AbstractDocument.getDocumentListeners() , getDocumentProperties sample code for javax.swing.text.AbstractDocument.getDocumentProperties() definition code for javax.swing.text.AbstractDocument.getDocumentProperties() , getEndPosition sample code for javax.swing.text.AbstractDocument.getEndPosition() definition code for javax.swing.text.AbstractDocument.getEndPosition() , getLength sample code for javax.swing.text.AbstractDocument.getLength() definition code for javax.swing.text.AbstractDocument.getLength() , getListeners sample code for javax.swing.text.AbstractDocument.getListeners(java.lang.Class) definition code for javax.swing.text.AbstractDocument.getListeners(java.lang.Class) , getProperty sample code for javax.swing.text.AbstractDocument.getProperty(java.lang.Object) definition code for javax.swing.text.AbstractDocument.getProperty(java.lang.Object) , getRootElements sample code for javax.swing.text.AbstractDocument.getRootElements() definition code for javax.swing.text.AbstractDocument.getRootElements() , getStartPosition sample code for javax.swing.text.AbstractDocument.getStartPosition() definition code for javax.swing.text.AbstractDocument.getStartPosition() , getText sample code for javax.swing.text.AbstractDocument.getText(int, int) definition code for javax.swing.text.AbstractDocument.getText(int, int) , getText sample code for javax.swing.text.AbstractDocument.getText(int, int, javax.swing.text.Segment) definition code for javax.swing.text.AbstractDocument.getText(int, int, javax.swing.text.Segment) , getUndoableEditListeners sample code for javax.swing.text.AbstractDocument.getUndoableEditListeners() definition code for javax.swing.text.AbstractDocument.getUndoableEditListeners() , insertString sample code for javax.swing.text.AbstractDocument.insertString(int, java.lang.String, javax.swing.text.AttributeSet) definition code for javax.swing.text.AbstractDocument.insertString(int, java.lang.String, javax.swing.text.AttributeSet) , postRemoveUpdate sample code for javax.swing.text.AbstractDocument.postRemoveUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent) definition code for javax.swing.text.AbstractDocument.postRemoveUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent) , putProperty sample code for javax.swing.text.AbstractDocument.putProperty(java.lang.Object, java.lang.Object) definition code for javax.swing.text.AbstractDocument.putProperty(java.lang.Object, java.lang.Object) , readLock sample code for javax.swing.text.AbstractDocument.readLock() definition code for javax.swing.text.AbstractDocument.readLock() , readUnlock sample code for javax.swing.text.AbstractDocument.readUnlock() definition code for javax.swing.text.AbstractDocument.readUnlock() , remove sample code for javax.swing.text.AbstractDocument.remove(int, int) definition code for javax.swing.text.AbstractDocument.remove(int, int) , removeUndoableEditListener sample code for javax.swing.text.AbstractDocument.removeUndoableEditListener(javax.swing.event.UndoableEditListener) definition code for javax.swing.text.AbstractDocument.removeUndoableEditListener(javax.swing.event.UndoableEditListener) , render sample code for javax.swing.text.AbstractDocument.render(java.lang.Runnable) definition code for javax.swing.text.AbstractDocument.render(java.lang.Runnable) , replace sample code for javax.swing.text.AbstractDocument.replace(int, int, java.lang.String, javax.swing.text.AttributeSet) definition code for javax.swing.text.AbstractDocument.replace(int, int, java.lang.String, javax.swing.text.AttributeSet) , setAsynchronousLoadPriority sample code for javax.swing.text.AbstractDocument.setAsynchronousLoadPriority(int) definition code for javax.swing.text.AbstractDocument.setAsynchronousLoadPriority(int) , setDocumentFilter sample code for javax.swing.text.AbstractDocument.setDocumentFilter(javax.swing.text.DocumentFilter) definition code for javax.swing.text.AbstractDocument.setDocumentFilter(javax.swing.text.DocumentFilter) , setDocumentProperties sample code for javax.swing.text.AbstractDocument.setDocumentProperties(java.util.Dictionary) definition code for javax.swing.text.AbstractDocument.setDocumentProperties(java.util.Dictionary) , writeLock sample code for javax.swing.text.AbstractDocument.writeLock() definition code for javax.swing.text.AbstractDocument.writeLock() , writeUnlock sample code for javax.swing.text.AbstractDocument.writeUnlock() definition code for javax.swing.text.AbstractDocument.writeUnlock()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 
Methods inherited from interface javax.swing.text.Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document
addUndoableEditListener sample code for javax.swing.text.Document.addUndoableEditListener(javax.swing.event.UndoableEditListener) definition code for javax.swing.text.Document.addUndoableEditListener(javax.swing.event.UndoableEditListener) , createPosition sample code for javax.swing.text.Document.createPosition(int) definition code for javax.swing.text.Document.createPosition(int) , getEndPosition sample code for javax.swing.text.Document.getEndPosition() definition code for javax.swing.text.Document.getEndPosition() , getLength sample code for javax.swing.text.Document.getLength() definition code for javax.swing.text.Document.getLength() , getProperty sample code for javax.swing.text.Document.getProperty(java.lang.Object) definition code for javax.swing.text.Document.getProperty(java.lang.Object) , getRootElements sample code for javax.swing.text.Document.getRootElements() definition code for javax.swing.text.Document.getRootElements() , getStartPosition sample code for javax.swing.text.Document.getStartPosition() definition code for javax.swing.text.Document.getStartPosition() , getText sample code for javax.swing.text.Document.getText(int, int) definition code for javax.swing.text.Document.getText(int, int) , getText sample code for javax.swing.text.Document.getText(int, int, javax.swing.text.Segment) definition code for javax.swing.text.Document.getText(int, int, javax.swing.text.Segment) , insertString sample code for javax.swing.text.Document.insertString(int, java.lang.String, javax.swing.text.AttributeSet) definition code for javax.swing.text.Document.insertString(int, java.lang.String, javax.swing.text.AttributeSet) , putProperty sample code for javax.swing.text.Document.putProperty(java.lang.Object, java.lang.Object) definition code for javax.swing.text.Document.putProperty(java.lang.Object, java.lang.Object) , remove sample code for javax.swing.text.Document.remove(int, int) definition code for javax.swing.text.Document.remove(int, int) , removeUndoableEditListener sample code for javax.swing.text.Document.removeUndoableEditListener(javax.swing.event.UndoableEditListener) definition code for javax.swing.text.Document.removeUndoableEditListener(javax.swing.event.UndoableEditListener) , render sample code for javax.swing.text.Document.render(java.lang.Runnable) definition code for javax.swing.text.Document.render(java.lang.Runnable)
 

Field Detail

AdditionalComments sample code for javax.swing.text.html.HTMLDocument.AdditionalComments

public static final String sample code for java.lang.String definition code for java.lang.String  AdditionalComments
Document property key value. The value for the key will be a Vector of Strings that are comments not found in the body.

See Also:
Constant Field Values
Constructor Detail

HTMLDocument sample code for javax.swing.text.html.HTMLDocument() definition code for javax.swing.text.html.HTMLDocument()

public HTMLDocument()
Constructs an HTML document using the default buffer size and a default StyleSheet. This is a convenience method for the constructor HTMLDocument(Content, StyleSheet).


HTMLDocument sample code for javax.swing.text.html.HTMLDocument(javax.swing.text.html.StyleSheet) definition code for javax.swing.text.html.HTMLDocument(javax.swing.text.html.StyleSheet)

public HTMLDocument(StyleSheet sample code for javax.swing.text.html.StyleSheet definition code for javax.swing.text.html.StyleSheet  styles)
Constructs an HTML document with the default content storage implementation and the specified style/attribute storage mechanism. This is a convenience method for the constructor HTMLDocument(Content, StyleSheet).

Parameters:
styles - the styles

HTMLDocument sample code for javax.swing.text.html.HTMLDocument(javax.swing.text.AbstractDocument.Content, javax.swing.text.html.StyleSheet) definition code for javax.swing.text.html.HTMLDocument(javax.swing.text.AbstractDocument.Content, javax.swing.text.html.StyleSheet)

public HTMLDocument(AbstractDocument.Content sample code for javax.swing.text.AbstractDocument.Content definition code for javax.swing.text.AbstractDocument.Content  c,
                    StyleSheet sample code for javax.swing.text.html.StyleSheet definition code for javax.swing.text.html.StyleSheet  styles)
Constructs an HTML document with the given content storage implementation and the given style/attribute storage mechanism.

Parameters:
c - the container for the content
styles - the styles
Method Detail

getReader sample code for javax.swing.text.html.HTMLDocument.getReader(int) definition code for javax.swing.text.html.HTMLDocument.getReader(int)

public HTMLEditorKit.ParserCallback sample code for javax.swing.text.html.HTMLEditorKit.ParserCallback definition code for javax.swing.text.html.HTMLEditorKit.ParserCallback  getReader(int pos)
Fetches the reader for the parser to use when loading the document with HTML. This is implemented to return an instance of HTMLDocument.HTMLReader. Subclasses can reimplement this method to change how the document gets structured if desired. (For example, to handle custom tags, or structurally represent character style elements.)

Parameters:
pos - the starting position
Returns:
the reader used by the parser to load the document

getReader sample code for javax.swing.text.html.HTMLDocument.getReader(int, int, int, javax.swing.text.html.HTML.Tag) definition code for javax.swing.text.html.HTMLDocument.getReader(int, int, int, javax.swing.text.html.HTML.Tag)

public HTMLEditorKit.ParserCallback sample code for javax.swing.text.html.HTMLEditorKit.ParserCallback definition code for javax.swing.text.html.HTMLEditorKit.ParserCallback  getReader(int pos,
                                              int popDepth,
                                              int pushDepth,
                                              HTML.Tag sample code for javax.swing.text.html.HTML.Tag definition code for javax.swing.text.html.HTML.Tag  insertTag)
Returns the reader for the parser to use to load the document with HTML. This is implemented to return an instance of HTMLDocument.HTMLReader. Subclasses can reimplement this method to change how the document gets structured if desired. (For example, to handle custom tags, or structurally represent character style elements.)

This is a convenience method for getReader(int, int, int, HTML.Tag, TRUE).

Parameters:
popDepth - the number of ElementSpec.EndTagTypes to generate before inserting
pushDepth - the number of ElementSpec.StartTagTypes with a direction of ElementSpec.JoinNextDirection that should be generated before inserting, but after the end tags have been generated
insertTag - the first tag to start inserting into document
Returns:
the reader used by the parser to load the document

getBase sample code for javax.swing.text.html.HTMLDocument.getBase() definition code for javax.swing.text.html.HTMLDocument.getBase()

public URL sample code for java.net.URL definition code for java.net.URL  getBase()
Returns the location to resolve relative URLs against. By default this will be the document's URL if the document was loaded from a URL. If a base tag is found and can be parsed, it will be used as the base location.

Returns:
the base location

setBase sample code for javax.swing.text.html.HTMLDocument.setBase(java.net.URL) definition code for javax.swing.text.html.HTMLDocument.setBase(java.net.URL)

public void setBase(URL sample code for java.net.URL definition code for java.net.URL  u)
Sets the location to resolve relative URLs against. By default this will be the document's URL if the document was loaded from a URL. If a base tag is found and can be parsed, it will be used as the base location.

This also sets the base of the StyleSheet to be u as well as the base of the document.

Parameters:
u - the desired base URL

insert sample code for javax.swing.text.html.HTMLDocument.insert(int, javax.swing.text.DefaultStyledDocument.ElementSpec[]) definition code for javax.swing.text.html.HTMLDocument.insert(int, javax.swing.text.DefaultStyledDocument.ElementSpec[])

protected void insert(int offset,
                      DefaultStyledDocument.ElementSpec sample code for javax.swing.text.DefaultStyledDocument.ElementSpec definition code for javax.swing.text.DefaultStyledDocument.ElementSpec [] data)
               throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException 
Inserts new elements in bulk. This is how elements get created in the document. The parsing determines what structure is needed and creates the specification as a set of tokens that describe the edit while leaving the document free of a write-lock. This method can then be called in bursts by the reader to acquire a write-lock for a shorter duration (i.e. while the document is actually being altered).

Overrides:
insert sample code for javax.swing.text.DefaultStyledDocument.insert(int, javax.swing.text.DefaultStyledDocument.ElementSpec[]) definition code for javax.swing.text.DefaultStyledDocument.insert(int, javax.swing.text.DefaultStyledDocument.ElementSpec[]) in class DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument
Parameters:
offset - the starting offset
data - the element data
Throws:
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException - if the given position does not represent a valid location in the associated document.

insertUpdate sample code for javax.swing.text.html.HTMLDocument.insertUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AttributeSet) definition code for javax.swing.text.html.HTMLDocument.insertUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AttributeSet)

protected void insertUpdate(AbstractDocument.DefaultDocumentEvent sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent  chng,
                            AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
Updates document structure as a result of text insertion. This will happen within a write lock. This implementation simply parses the inserted content for line breaks and builds up a set of instructions for the element buffer.

Overrides:
insertUpdate sample code for javax.swing.text.DefaultStyledDocument.insertUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AttributeSet) definition code for javax.swing.text.DefaultStyledDocument.insertUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AttributeSet) in class DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument
Parameters:
chng - a description of the document change
attr - the attributes

create sample code for javax.swing.text.html.HTMLDocument.create(javax.swing.text.DefaultStyledDocument.ElementSpec[]) definition code for javax.swing.text.html.HTMLDocument.create(javax.swing.text.DefaultStyledDocument.ElementSpec[])

protected void create(DefaultStyledDocument.ElementSpec sample code for javax.swing.text.DefaultStyledDocument.ElementSpec definition code for javax.swing.text.DefaultStyledDocument.ElementSpec [] data)
Replaces the contents of the document with the given element specifications. This is called before insert if the loading is done in bursts. This is the only method called if loading the document entirely in one burst.

Overrides:
create sample code for javax.swing.text.DefaultStyledDocument.create(javax.swing.text.DefaultStyledDocument.ElementSpec[]) definition code for javax.swing.text.DefaultStyledDocument.create(javax.swing.text.DefaultStyledDocument.ElementSpec[]) in class DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument
Parameters:
data - the new contents of the document

setParagraphAttributes sample code for javax.swing.text.html.HTMLDocument.setParagraphAttributes(int, int, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.html.HTMLDocument.setParagraphAttributes(int, int, javax.swing.text.AttributeSet, boolean)

public void setParagraphAttributes(int offset,
                                   int length,
                                   AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  s,
                                   boolean replace)
Sets attributes for a paragraph.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Specified by:
setParagraphAttributes sample code for javax.swing.text.StyledDocument.setParagraphAttributes(int, int, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.StyledDocument.setParagraphAttributes(int, int, javax.swing.text.AttributeSet, boolean) in interface StyledDocument sample code for javax.swing.text.StyledDocument definition code for javax.swing.text.StyledDocument
Overrides:
setParagraphAttributes sample code for javax.swing.text.DefaultStyledDocument.setParagraphAttributes(int, int, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.DefaultStyledDocument.setParagraphAttributes(int, int, javax.swing.text.AttributeSet, boolean) in class DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument
Parameters:
offset - the offset into the paragraph (must be at least 0)
length - the number of characters affected (must be at least 0)
s - the attributes
replace - whether to replace existing attributes, or merge them

getStyleSheet sample code for javax.swing.text.html.HTMLDocument.getStyleSheet() definition code for javax.swing.text.html.HTMLDocument.getStyleSheet()

public StyleSheet sample code for javax.swing.text.html.StyleSheet definition code for javax.swing.text.html.StyleSheet  getStyleSheet()
Fetches the StyleSheet with the document-specific display rules (CSS) that were specified in the HTML document itself.

Returns:
the StyleSheet

getIterator sample code for javax.swing.text.html.HTMLDocument.getIterator(javax.swing.text.html.HTML.Tag) definition code for javax.swing.text.html.HTMLDocument.getIterator(javax.swing.text.html.HTML.Tag)

public HTMLDocument.Iterator sample code for javax.swing.text.html.HTMLDocument.Iterator definition code for javax.swing.text.html.HTMLDocument.Iterator  getIterator(HTML.Tag sample code for javax.swing.text.html.HTML.Tag definition code for javax.swing.text.html.HTML.Tag  t)
Fetches an iterator for the specified HTML tag. This can be used for things like iterating over the set of anchors contained, or iterating over the input elements.

Parameters:
t - the requested HTML.Tag
Returns:
the Iterator for the given HTML tag
See Also:
HTML.Tag sample code for javax.swing.text.html.HTML.Tag definition code for javax.swing.text.html.HTML.Tag

createLeafElement sample code for javax.swing.text.html.HTMLDocument.createLeafElement(javax.swing.text.Element, javax.swing.text.AttributeSet, int, int) definition code for javax.swing.text.html.HTMLDocument.createLeafElement(javax.swing.text.Element, javax.swing.text.AttributeSet, int, int)

protected Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  createLeafElement(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  parent,
                                    AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a,
                                    int p0,
                                    int p1)
Creates a document leaf element that directly represents text (doesn't have any children). This is implemented to return an element of type HTMLDocument.RunElement.

Overrides:
createLeafElement sample code for javax.swing.text.AbstractDocument.createLeafElement(javax.swing.text.Element, javax.swing.text.AttributeSet, int, int) definition code for javax.swing.text.AbstractDocument.createLeafElement(javax.swing.text.Element, javax.swing.text.AttributeSet, int, int) in class AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument
Parameters:
parent - the parent element
a - the attributes for the element
p0 - the beginning of the range (must be at least 0)
p1 - the end of the range (must be at least p0)
Returns:
the new element

createBranchElement sample code for javax.swing.text.html.HTMLDocument.createBranchElement(javax.swing.text.Element, javax.swing.text.AttributeSet) definition code for javax.swing.text.html.HTMLDocument.createBranchElement(javax.swing.text.Element, javax.swing.text.AttributeSet)

protected Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  createBranchElement(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  parent,
                                      AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
Creates a document branch element, that can contain other elements. This is implemented to return an element of type HTMLDocument.BlockElement.

Overrides:
createBranchElement sample code for javax.swing.text.AbstractDocument.createBranchElement(javax.swing.text.Element, javax.swing.text.AttributeSet) definition code for javax.swing.text.AbstractDocument.createBranchElement(javax.swing.text.Element, javax.swing.text.AttributeSet) in class AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument
Parameters:
parent - the parent element
a - the attributes
Returns:
the element

createDefaultRoot sample code for javax.swing.text.html.HTMLDocument.createDefaultRoot() definition code for javax.swing.text.html.HTMLDocument.createDefaultRoot()

protected AbstractDocument.AbstractElement sample code for javax.swing.text.AbstractDocument.AbstractElement definition code for javax.swing.text.AbstractDocument.AbstractElement  createDefaultRoot()
Creates the root element to be used to represent the default document structure.

Overrides:
createDefaultRoot sample code for javax.swing.text.DefaultStyledDocument.createDefaultRoot() definition code for javax.swing.text.DefaultStyledDocument.createDefaultRoot() in class DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument
Returns:
the element base

setTokenThreshold sample code for javax.swing.text.html.HTMLDocument.setTokenThreshold(int) definition code for javax.swing.text.html.HTMLDocument.setTokenThreshold(int)

public void setTokenThreshold(int n)
Sets the number of tokens to buffer before trying to update the documents element structure.

Parameters:
n - the number of tokens to buffer

getTokenThreshold sample code for javax.swing.text.html.HTMLDocument.getTokenThreshold() definition code for javax.swing.text.html.HTMLDocument.getTokenThreshold()

public int getTokenThreshold()
Gets the number of tokens to buffer before trying to update the documents element structure. The default value is Integer.MAX_VALUE.

Returns:
the number of tokens to buffer

setPreservesUnknownTags sample code for javax.swing.text.html.HTMLDocument.setPreservesUnknownTags(boolean) definition code for javax.swing.text.html.HTMLDocument.setPreservesUnknownTags(boolean)

public void setPreservesUnknownTags(boolean preservesTags)
Determines how unknown tags are handled by the parser. If set to true, unknown tags are put in the model, otherwise they are dropped.

Parameters:
preservesTags - true if unknown tags should be saved in the model, otherwise tags are dropped
See Also:
HTML.Tag sample code for javax.swing.text.html.HTML.Tag definition code for javax.swing.text.html.HTML.Tag

getPreservesUnknownTags sample code for javax.swing.text.html.HTMLDocument.getPreservesUnknownTags() definition code for javax.swing.text.html.HTMLDocument.getPreservesUnknownTags()

public boolean getPreservesUnknownTags()
Returns the behavior the parser observes when encountering unknown tags.

Returns:
true if unknown tags are to be preserved when parsing
See Also:
HTML.Tag sample code for javax.swing.text.html.HTML.Tag definition code for javax.swing.text.html.HTML.Tag

processHTMLFrameHyperlinkEvent sample code for javax.swing.text.html.HTMLDocument.processHTMLFrameHyperlinkEvent(javax.swing.text.html.HTMLFrameHyperlinkEvent) definition code for javax.swing.text.html.HTMLDocument.processHTMLFrameHyperlinkEvent(javax.swing.text.html.HTMLFrameHyperlinkEvent)

public void processHTMLFrameHyperlinkEvent(HTMLFrameHyperlinkEvent sample code for javax.swing.text.html.HTMLFrameHyperlinkEvent definition code for javax.swing.text.html.HTMLFrameHyperlinkEvent  e)
Processes HyperlinkEvents that are generated by documents in an HTML frame. The HyperlinkEvent type, as the parameter suggests, is HTMLFrameHyperlinkEvent. In addition to the typical information contained in a HyperlinkEvent, this event contains the element that corresponds to the frame in which the click happened (the source element) and the target name. The target name has 4 possible values: If target is _self, the action is to change the value of the HTML.Attribute.SRC attribute and fires a ChangedUpdate event.

If the target is _parent, then it deletes the parent element, which is a <FRAMESET> element, and inserts a new <FRAME> element, and sets its HTML.Attribute.SRC attribute to have a value equal to the destination URL and fire a RemovedUpdate and InsertUpdate.

If the target is _top, this method does nothing. In the implementation of the view for a frame, namely the FrameView, the processing of _top is handled. Given that _top implies replacing the entire document, it made sense to handle this outside of the document that it will replace.

If the target is a named frame, then the element hierarchy is searched for an element with a name equal to the target, its HTML.Attribute.SRC attribute is updated and a ChangedUpdate event is fired.

Parameters:
e - the event

setParser sample code for javax.swing.text.html.HTMLDocument.setParser(javax.swing.text.html.HTMLEditorKit.Parser) definition code for javax.swing.text.html.HTMLDocument.setParser(javax.swing.text.html.HTMLEditorKit.Parser)

public void setParser(HTMLEditorKit.Parser sample code for javax.swing.text.html.HTMLEditorKit.Parser definition code for javax.swing.text.html.HTMLEditorKit.Parser  parser)
Sets the parser that is used by the methods that insert html into the existing document, such as setInnerHTML, and setOuterHTML.

HTMLEditorKit.createDefaultDocument will set the parser for you. If you create an HTMLDocument by hand, be sure and set the parser accordingly.

Parameters:
parser - the parser to be used for text insertion
Since:
1.3

getParser sample code for javax.swing.text.html.HTMLDocument.getParser() definition code for javax.swing.text.html.HTMLDocument.getParser()

public HTMLEditorKit.Parser sample code for javax.swing.text.html.HTMLEditorKit.Parser definition code for javax.swing.text.html.HTMLEditorKit.Parser  getParser()
Returns the parser that is used when inserting HTML into the existing document.

Returns:
the parser used for text insertion
Since:
1.3

setInnerHTML sample code for javax.swing.text.html.HTMLDocument.setInnerHTML(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.setInnerHTML(javax.swing.text.Element, java.lang.String)

public void setInnerHTML(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem,
                         String sample code for java.lang.String definition code for java.lang.String  htmlText)
                  throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException ,
                         IOException sample code for java.io.IOException definition code for java.io.IOException 
Replaces the children of the given element with the contents specified as an HTML string.

This will be seen as at least two events, n inserts followed by a remove.

For this to work correcty, the document must have an HTMLEditorKit.Parser set. This will be the case if the document was created from an HTMLEditorKit via the createDefaultDocument method.

Parameters:
elem - the branch element whose children will be replaced
htmlText - the string to be parsed and assigned to elem
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if elem is a leaf
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if an HTMLEditorKit.Parser has not been defined
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException
IOException sample code for java.io.IOException definition code for java.io.IOException
Since:
1.3

setOuterHTML sample code for javax.swing.text.html.HTMLDocument.setOuterHTML(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.setOuterHTML(javax.swing.text.Element, java.lang.String)

public void setOuterHTML(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem,
                         String sample code for java.lang.String definition code for java.lang.String  htmlText)
                  throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException ,
                         IOException sample code for java.io.IOException definition code for java.io.IOException 
Replaces the given element in the parent with the contents specified as an HTML string.

This will be seen as at least two events, n inserts followed by a remove.

When replacing a leaf this will attempt to make sure there is a newline present if one is needed. This may result in an additional element being inserted. Consider, if you were to replace a character element that contained a newline with <img> this would create two elements, one for the image, ane one for the newline.

If you try to replace the element at length you will most likely end up with two elements, eg setOuterHTML(getCharacterElement (getLength()), "blah") will result in two leaf elements at the end, one representing 'blah', and the other representing the end element.

For this to work correcty, the document must have an HTMLEditorKit.Parser set. This will be the case if the document was created from an HTMLEditorKit via the createDefaultDocument method.

Parameters:
elem - the branch element whose children will be replaced
htmlText - the string to be parsed and assigned to elem
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if an HTMLEditorKit.Parser has not been set
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException
IOException sample code for java.io.IOException definition code for java.io.IOException
Since:
1.3

insertAfterStart sample code for javax.swing.text.html.HTMLDocument.insertAfterStart(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.insertAfterStart(javax.swing.text.Element, java.lang.String)

public void insertAfterStart(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem,
                             String sample code for java.lang.String definition code for java.lang.String  htmlText)
                      throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException ,
                             IOException sample code for java.io.IOException definition code for java.io.IOException 
Inserts the HTML specified as a string at the start of the element.

For this to work correcty, the document must have an HTMLEditorKit.Parser set. This will be the case if the document was created from an HTMLEditorKit via the createDefaultDocument method.

Parameters:
elem - the branch element to be the root for the new text
htmlText - the string to be parsed and assigned to elem
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if an HTMLEditorKit.Parser has not been set on the document
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException
IOException sample code for java.io.IOException definition code for java.io.IOException
Since:
1.3

insertBeforeEnd sample code for javax.swing.text.html.HTMLDocument.insertBeforeEnd(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.insertBeforeEnd(javax.swing.text.Element, java.lang.String)

public void insertBeforeEnd(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem,
                            String sample code for java.lang.String definition code for java.lang.String  htmlText)
                     throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException ,
                            IOException sample code for java.io.IOException definition code for java.io.IOException 
Inserts the HTML specified as a string at the end of the element.

If elem's children are leaves, and the character at a elem.getEndOffset() - 1 is a newline, this will insert before the newline so that there isn't text after the newline.

For this to work correcty, the document must have an HTMLEditorKit.Parser set. This will be the case if the document was created from an HTMLEditorKit via the createDefaultDocument method.

Parameters:
elem - the element to be the root for the new text
htmlText - the string to be parsed and assigned to elem
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if an HTMLEditorKit.Parser has not been set on the document
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException
IOException sample code for java.io.IOException definition code for java.io.IOException
Since:
1.3

insertBeforeStart sample code for javax.swing.text.html.HTMLDocument.insertBeforeStart(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.insertBeforeStart(javax.swing.text.Element, java.lang.String)

public void insertBeforeStart(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem,
                              String sample code for java.lang.String definition code for java.lang.String  htmlText)
                       throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException ,
                              IOException sample code for java.io.IOException definition code for java.io.IOException 
Inserts the HTML specified as a string before the start of the given element.

For this to work correcty, the document must have an HTMLEditorKit.Parser set. This will be the case if the document was created from an HTMLEditorKit via the createDefaultDocument method.

Parameters:
elem - the element to be the root for the new text
htmlText - the string to be parsed and assigned to elem
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if an HTMLEditorKit.Parser has not been set on the document
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException
IOException sample code for java.io.IOException definition code for java.io.IOException
Since:
1.3

insertAfterEnd sample code for javax.swing.text.html.HTMLDocument.insertAfterEnd(javax.swing.text.Element, java.lang.String) definition code for javax.swing.text.html.HTMLDocument.insertAfterEnd(javax.swing.text.Element, java.lang.String)

public void insertAfterEnd(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem,
                           String sample code for java.lang.String definition code for java.lang.String  htmlText)
                    throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException ,
                           IOException sample code for java.io.IOException definition code for java.io.IOException 
Inserts the HTML specified as a string after the the end of the given element.

For this to work correcty, the document must have an HTMLEditorKit.Parser set. This will be the case if the document was created from an HTMLEditorKit via the createDefaultDocument method.

Parameters:
elem - the element to be the root for the new text
htmlText - the string to be parsed and assigned to elem
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if an HTMLEditorKit.Parser has not been set on the document
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException
IOException sample code for java.io.IOException definition code for java.io.IOException
Since:
1.3

getElement sample code for javax.swing.text.html.HTMLDocument.getElement(java.lang.String) definition code for javax.swing.text.html.HTMLDocument.getElement(java.lang.String)

public Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  getElement(String sample code for java.lang.String definition code for java.lang.String  id)
Returns the element that has the given id Attribute. If the element can't be found, null is returned. Note that this method works on an Attribute, not a character tag. In the following HTML snippet: <a id="HelloThere"> the attribute is 'id' and the character tag is 'a'. This is a convenience method for getElement(RootElement, HTML.Attribute.id, id). This is not thread-safe.

Parameters:
id - the string representing the desired Attribute
Returns:
the element with the specified Attribute or null if it can't be found, or null if id is null
Since:
1.3
See Also:
HTML.Attribute sample code for javax.swing.text.html.HTML.Attribute definition code for javax.swing.text.html.HTML.Attribute

getElement sample code for javax.swing.text.html.HTMLDocument.getElement(javax.swing.text.Element, java.lang.Object, java.lang.Object) definition code for javax.swing.text.html.HTMLDocument.getElement(javax.swing.text.Element, java.lang.Object, java.lang.Object)

public Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  getElement(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  e,
                          Object sample code for java.lang.Object definition code for java.lang.Object  attribute,
                          Object sample code for java.lang.Object definition code for java.lang.Object  value)
Returns the child element of e that contains the attribute, attribute with value value, or null if one isn't found. This is not thread-safe.

Parameters:
e - the root element where the search begins
attribute - the desired Attribute
value - the values for the specified Attribute
Returns:
the element with the specified Attribute and the specified value, or null if it can't be found
Since:
1.3
See Also:
HTML.Attribute sample code for javax.swing.text.html.HTML.Attribute definition code for javax.swing.text.html.HTML.Attribute

fireChangedUpdate sample code for javax.swing.text.html.HTMLDocument.fireChangedUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.text.html.HTMLDocument.fireChangedUpdate(javax.swing.event.DocumentEvent)

protected void fireChangedUpdate(DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent  e)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Overrides:
fireChangedUpdate sample code for javax.swing.text.AbstractDocument.fireChangedUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.text.AbstractDocument.fireChangedUpdate(javax.swing.event.DocumentEvent) in class AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument
Parameters:
e - the event
See Also:
EventListenerList sample code for javax.swing.event.EventListenerList definition code for javax.swing.event.EventListenerList

fireUndoableEditUpdate sample code for javax.swing.text.html.HTMLDocument.fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent) definition code for javax.swing.text.html.HTMLDocument.fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent)

protected void fireUndoableEditUpdate(UndoableEditEvent sample code for javax.swing.event.UndoableEditEvent definition code for javax.swing.event.UndoableEditEvent  e)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Overrides:
fireUndoableEditUpdate sample code for javax.swing.text.AbstractDocument.fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent) definition code for javax.swing.text.AbstractDocument.fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent) in class AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument
Parameters:
e - the event
See Also:
EventListenerList sample code for javax.swing.event.EventListenerList definition code for javax.swing.event.EventListenerList