javax.swing.text
Interface StyledDocument

All Superinterfaces:
Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document
All Known Implementing Classes:
DefaultStyledDocument sample code for javax.swing.text.DefaultStyledDocument definition code for javax.swing.text.DefaultStyledDocument , HTMLDocument sample code for javax.swing.text.html.HTMLDocument definition code for javax.swing.text.html.HTMLDocument

public interface StyledDocument
extends Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document

Interface for a generic styled document.


Field Summary
 
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
 
Method Summary
 Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style addStyle sample code for javax.swing.text.StyledDocument.addStyle(java.lang.String, javax.swing.text.Style) definition code for javax.swing.text.StyledDocument.addStyle(java.lang.String, javax.swing.text.Style) (String sample code for java.lang.String definition code for java.lang.String  nm, Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  parent)
          Adds a new style into the logical style hierarchy.
 Color sample code for java.awt.Color definition code for java.awt.Color getBackground sample code for javax.swing.text.StyledDocument.getBackground(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyledDocument.getBackground(javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
          Takes a set of attributes and turn it into a background color specification.
 Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element getCharacterElement sample code for javax.swing.text.StyledDocument.getCharacterElement(int) definition code for javax.swing.text.StyledDocument.getCharacterElement(int) (int pos)
          Gets the element that represents the character that is at the given offset within the document.
 Font sample code for java.awt.Font definition code for java.awt.Font getFont sample code for javax.swing.text.StyledDocument.getFont(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyledDocument.getFont(javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
          Takes a set of attributes and turn it into a font specification.
 Color sample code for java.awt.Color definition code for java.awt.Color getForeground sample code for javax.swing.text.StyledDocument.getForeground(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyledDocument.getForeground(javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
          Takes a set of attributes and turn it into a foreground color specification.
 Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style getLogicalStyle sample code for javax.swing.text.StyledDocument.getLogicalStyle(int) definition code for javax.swing.text.StyledDocument.getLogicalStyle(int) (int p)
          Gets a logical style for a given position in a paragraph.
 Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element getParagraphElement sample code for javax.swing.text.StyledDocument.getParagraphElement(int) definition code for javax.swing.text.StyledDocument.getParagraphElement(int) (int pos)
          Gets the element that represents the paragraph that encloses the given offset within the document.
 Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style getStyle sample code for javax.swing.text.StyledDocument.getStyle(java.lang.String) definition code for javax.swing.text.StyledDocument.getStyle(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  nm)
          Fetches a named style previously added.
 void removeStyle sample code for javax.swing.text.StyledDocument.removeStyle(java.lang.String) definition code for javax.swing.text.StyledDocument.removeStyle(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  nm)
          Removes a named style previously added to the document.
 void setCharacterAttributes sample code for javax.swing.text.StyledDocument.setCharacterAttributes(int, int, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.StyledDocument.setCharacterAttributes(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)
          Changes the content element attributes used for the given range of existing content in the document.
 void setLogicalStyle sample code for javax.swing.text.StyledDocument.setLogicalStyle(int, javax.swing.text.Style) definition code for javax.swing.text.StyledDocument.setLogicalStyle(int, javax.swing.text.Style) (int pos, Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  s)
          Sets the logical style to use for the paragraph at the given position.
 void 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) (int offset, int length, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  s, boolean replace)
          Sets paragraph attributes.
 
Methods inherited from interface javax.swing.text.Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document
addDocumentListener sample code for javax.swing.text.Document.addDocumentListener(javax.swing.event.DocumentListener) definition code for javax.swing.text.Document.addDocumentListener(javax.swing.event.DocumentListener) , 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) , getDefaultRootElement sample code for javax.swing.text.Document.getDefaultRootElement() definition code for javax.swing.text.Document.getDefaultRootElement() , 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) , removeDocumentListener sample code for javax.swing.text.Document.removeDocumentListener(javax.swing.event.DocumentListener) definition code for javax.swing.text.Document.removeDocumentListener(javax.swing.event.DocumentListener) , 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)
 

Method Detail

addStyle sample code for javax.swing.text.StyledDocument.addStyle(java.lang.String, javax.swing.text.Style) definition code for javax.swing.text.StyledDocument.addStyle(java.lang.String, javax.swing.text.Style)

Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  addStyle(String sample code for java.lang.String definition code for java.lang.String  nm,
               Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  parent)
Adds a new style into the logical style hierarchy. Style attributes resolve from bottom up so an attribute specified in a child will override an attribute specified in the parent.

Parameters:
nm - the name of the style (must be unique within the collection of named styles). The name may be null if the style is unnamed, but the caller is responsible for managing the reference returned as an unnamed style can't be fetched by name. An unnamed style may be useful for things like character attribute overrides such as found in a style run.
parent - the parent style. This may be null if unspecified attributes need not be resolved in some other style.
Returns:
the style

removeStyle sample code for javax.swing.text.StyledDocument.removeStyle(java.lang.String) definition code for javax.swing.text.StyledDocument.removeStyle(java.lang.String)

void removeStyle(String sample code for java.lang.String definition code for java.lang.String  nm)
Removes a named style previously added to the document.

Parameters:
nm - the name of the style to remove

getStyle sample code for javax.swing.text.StyledDocument.getStyle(java.lang.String) definition code for javax.swing.text.StyledDocument.getStyle(java.lang.String)

Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  getStyle(String sample code for java.lang.String definition code for java.lang.String  nm)
Fetches a named style previously added.

Parameters:
nm - the name of the style
Returns:
the style

setCharacterAttributes sample code for javax.swing.text.StyledDocument.setCharacterAttributes(int, int, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.StyledDocument.setCharacterAttributes(int, int, javax.swing.text.AttributeSet, boolean)

void setCharacterAttributes(int offset,
                            int length,
                            AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  s,
                            boolean replace)
Changes the content element attributes used for the given range of existing content in the document. All of the attributes defined in the given Attributes argument are applied to the given range. This method can be used to completely remove all content level attributes for the given range by giving an Attributes argument that has no attributes defined and setting replace to true.

Parameters:
offset - the start of the change >= 0
length - the length of the change >= 0
s - the non-null attributes to change to. Any attributes defined will be applied to the text for the given range.
replace - indicates whether or not the previous attributes should be cleared before the new attributes as set. If true, the operation will replace the previous attributes entirely. If false, the new attributes will be merged with the previous attributes.

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)

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 paragraph attributes.

Parameters:
offset - the start of the change >= 0
length - the length of the change >= 0
s - the non-null attributes to change to. Any attributes defined will be applied to the text for the given range.
replace - indicates whether or not the previous attributes should be cleared before the new attributes are set. If true, the operation will replace the previous attributes entirely. If false, the new attributes will be merged with the previous attributes.

setLogicalStyle sample code for javax.swing.text.StyledDocument.setLogicalStyle(int, javax.swing.text.Style) definition code for javax.swing.text.StyledDocument.setLogicalStyle(int, javax.swing.text.Style)

void setLogicalStyle(int pos,
                     Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  s)
Sets the logical style to use for the paragraph at the given position. If attributes aren't explicitly set for character and paragraph attributes they will resolve through the logical style assigned to the paragraph, which in turn may resolve through some hierarchy completely independent of the element hierarchy in the document.

Parameters:
pos - the starting position >= 0
s - the style to set

getLogicalStyle sample code for javax.swing.text.StyledDocument.getLogicalStyle(int) definition code for javax.swing.text.StyledDocument.getLogicalStyle(int)

Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  getLogicalStyle(int p)
Gets a logical style for a given position in a paragraph.

Parameters:
p - the position >= 0
Returns:
the style

getParagraphElement sample code for javax.swing.text.StyledDocument.getParagraphElement(int) definition code for javax.swing.text.StyledDocument.getParagraphElement(int)

Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  getParagraphElement(int pos)
Gets the element that represents the paragraph that encloses the given offset within the document.

Parameters:
pos - the offset >= 0
Returns:
the element

getCharacterElement sample code for javax.swing.text.StyledDocument.getCharacterElement(int) definition code for javax.swing.text.StyledDocument.getCharacterElement(int)

Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  getCharacterElement(int pos)
Gets the element that represents the character that is at the given offset within the document.

Parameters:
pos - the offset >= 0
Returns:
the element

getForeground sample code for javax.swing.text.StyledDocument.getForeground(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyledDocument.getForeground(javax.swing.text.AttributeSet)

Color sample code for java.awt.Color definition code for java.awt.Color  getForeground(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
Takes a set of attributes and turn it into a foreground color specification. This might be used to specify things like brighter, more hue, etc.

Parameters:
attr - the set of attributes
Returns:
the color

getBackground sample code for javax.swing.text.StyledDocument.getBackground(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyledDocument.getBackground(javax.swing.text.AttributeSet)

Color sample code for java.awt.Color definition code for java.awt.Color  getBackground(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
Takes a set of attributes and turn it into a background color specification. This might be used to specify things like brighter, more hue, etc.

Parameters:
attr - the set of attributes
Returns:
the color

getFont sample code for javax.swing.text.StyledDocument.getFont(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyledDocument.getFont(javax.swing.text.AttributeSet)

Font sample code for java.awt.Font definition code for java.awt.Font  getFont(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
Takes a set of attributes and turn it into a font specification. This can be used to turn things like family, style, size, etc into a font that is available on the system the document is currently being used on.

Parameters:
attr - the set of attributes
Returns:
the font