public final class StringContent extends Object implements AbstractDocument.Content, Serializable
通常建议使用间隙缓冲区或片表实现。 该缓冲区不会扩展到大尺寸。
 警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,支持所有JavaBeans的长期存储已经添加到java.beans包中。 请参阅XMLEncoder 。 
| Constructor and Description | 
|---|
| StringContent()
              创建一个新的StringContent对象。 
             | 
| StringContent(int initialLength)
              创建一个新的StringContent对象,并指定初始大小。 
             | 
| Modifier and Type | Method and Description | 
|---|---|
| Position | createPosition(int offset)
              在内容中创建一个位置,该内容将随内容突变而跟踪更改。 
             | 
| void | getChars(int where, int len, Segment chars)
              检索一部分内容。 
             | 
| protected Vector | getPositionsInRange(Vector v, int offset, int length)
              返回一个Vector,其中包含UndoPosRef的实例,其位置范围为 
              offset至offset+length。 | 
| String | getString(int where, int len)
              检索一部分内容。 
             | 
| UndoableEdit | insertString(int where, String str)
              在内容中插入一个字符串。 
             | 
| int | length()
              返回内容的长度。 
             | 
| UndoableEdit | remove(int where, int nitems)
              删除部分内容。 
             | 
| protected void | updateUndoPositions(Vector positions)
              重置positions中所有UndoPosRef实例的 
              positions。 | 
public StringContent()
public StringContent(int initialLength)
initialLength - 初始尺寸 
           public int length()
length在界面 
            AbstractDocument.Content 
           AbstractDocument.Content.length() 
           public UndoableEdit insertString(int where, String str) throws BadLocationException
insertString在界面 
            AbstractDocument.Content 
           where - 起始位置> = 0 && <length() 
           str - 要插入的非空字符串 
           BadLocationException - 如果指定的位置无效 
           AbstractDocument.Content.insertString(int, java.lang.String) 
           public UndoableEdit remove(int where, int nitems) throws BadLocationException
remove在界面 
            AbstractDocument.Content 
           where - 起始位置> = 0 
           nitems - 要删除的字符数> = 0 
           BadLocationException - 如果指定的位置无效 
           AbstractDocument.Content.remove(int, int) 
           public String getString(int where, int len) throws BadLocationException
getString在接口 
            AbstractDocument.Content 
           where - 起始位置> = 0 
           len - 要检索的长度> = 0 
           BadLocationException - 如果指定的位置无效 
           AbstractDocument.Content.getString(int, int) 
           public void getChars(int where,
                     int len,
                     Segment chars)
              throws BadLocationException 
          getChars在界面 
            AbstractDocument.Content 
           where - 起始位置> = 0 
           len - 要检索的字符数> = 0 
           chars - 要返回字符的Segment对象 
           BadLocationException - 如果指定的位置无效 
           AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment) 
           public Position createPosition(int offset) throws BadLocationException
createPosition在界面 
            AbstractDocument.Content 
           offset - 为> = 0创建位置的偏移量 
           BadLocationException - 如果指定的位置无效 
           protected Vector getPositionsInRange(Vector v, int offset, int length)
offset至offset + length 。 
           如果v不为空,则匹配的位置放在那里。 
           返回带有结果位置的向量。 
           这是为了内部使用,通常不是子类的兴趣。
v - 要使用的向量,在null上创建一个新的 
           offset - 起始偏移量> = 0 
           length - 长度> = 0 
           protected void updateUndoPositions(Vector positions)
positions 。 
           这是为了内部使用,通常不是子类的兴趣。
positions - 实例的位置 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.