|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Document
A Document is the model that backs up all text components in Swing. This interface supports different kinds of implementations, from simple plain text model up to complex styled HTML or RTF models.
Field Summary | |
---|---|
static String |
StreamDescriptionProperty
The key for the property that describes the source of a document. |
static String |
TitleProperty
The key for the property that is the title of a document. |
Method Summary | |
---|---|
void |
addDocumentListener(DocumentListener listener)
Adds a DocumentListener to this document. |
void |
addUndoableEditListener(UndoableEditListener listener)
Adds an UndoableEditListener to this document. |
Position |
createPosition(int offs)
Creates a mark in the character content at the specified offset. |
Element |
getDefaultRootElement()
Returns the default root element. |
Position |
getEndPosition()
Returns the position that marks the end of the document. |
int |
getLength()
Returns the length of the document content. |
Object |
getProperty(Object key)
Returns a document property with the specified key. |
Element[] |
getRootElements()
Returns the root elements of the document content. |
Position |
getStartPosition()
Returns the position that marks the beginning of the document content. |
String |
getText(int offset,
int length)
Returns the textual content starting at offset with
a length of length . |
void |
getText(int offset,
int length,
Segment txt)
Fetch the textual content starting at offset with
a length of length and store it in txt . |
void |
insertString(int offset,
String str,
AttributeSet a)
Inserts a piece of text with an AttributeSet at the specified offset . |
void |
putProperty(Object key,
Object value)
Sets a document property. |
void |
remove(int offs,
int len)
Removes a piece of content. |
void |
removeDocumentListener(DocumentListener listener)
Removes a DocumentListener from this Document. |
void |
removeUndoableEditListener(UndoableEditListener listener)
Removes an UndoableEditListener from this Document. |
void |
render(Runnable r)
This allows the Document to be rendered safely. |
Field Detail |
---|
static final String StreamDescriptionProperty
static final String TitleProperty
Method Detail |
---|
void addDocumentListener(DocumentListener listener)
DocumentListener
to this document.
listener
- the DocumentListener to addvoid addUndoableEditListener(UndoableEditListener listener)
UndoableEditListener
to this document.
listener
- the UndoableEditListener to addPosition createPosition(int offs) throws BadLocationException
offs
- the offset where to place the mark
BadLocationException
- of the specified offset is not a valid
position in the documents contentElement getDefaultRootElement()
Position getEndPosition()
int getLength()
Object getProperty(Object key)
key
- the (non-null) key for the property to fetch
key
or null if no such property
is storedElement[] getRootElements()
Position getStartPosition()
String getText(int offset, int length) throws BadLocationException
offset
with
a length of length
.
offset
- the beginning of the text fragment to fetchlength
- the length of the text fragment to fetch
offset
with
a length of length
BadLocationException
- if offset
or length
are no valid locations in the document contentvoid getText(int offset, int length, Segment txt) throws BadLocationException
offset
with
a length of length
and store it in txt
.
offset
- the beginning of the text fragment to fetchlength
- the length of the text fragment to fetchtxt
- the Segment where to store the text fragment
BadLocationException
- if offset
or length
are no valid locations in the document contentvoid insertString(int offset, String str, AttributeSet a) throws BadLocationException
offset
.
offset
- the location where to insert the contentstr
- the textual content to inserta
- the Attributes associated with the piece of text
BadLocationException
- if offset
is not a valid location in the document contentvoid putProperty(Object key, Object value)
key
- the key of the propertyvalue
- the value of the propertyvoid remove(int offs, int len) throws BadLocationException
offs
- the location of the fragment to removelen
- the length of the fragment to remove
BadLocationException
- if offs
or len
are no valid locations in the document contentvoid removeDocumentListener(DocumentListener listener)
listener
- the DocumentListener to removevoid removeUndoableEditListener(UndoableEditListener listener)
listener
- the UndoableEditListener to removevoid render(Runnable r)
r
- the Runnable that renders the Document
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |