- java.lang.Object
 -  
      
- javax.swing.text.StringContent
 
 
-  
       
- 实现的所有接口
 -  
         
Serializable,AbstractDocument.Content 
public final class StringContent extends Object implements AbstractDocument.Content, Serializable
AbstractDocument.Content接口的实现,它是一种强力实现,对于相对较小的文档和/或调试很有用。 它将角色内容作为简单的字符数组进行管理。 这也是非常低效的。通常建议使用间隙缓冲区或片表实现。 此缓冲区不能扩展到大尺寸。
警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储或RMI。 从1.4开始,
java.beans软件包中添加了对所有JavaBeansjava.beans长期存储的支持。 请参阅XMLEncoder。- 另请参见:
 - Serialized Form
 
 
-  
        
       
-  
             
构造方法摘要
构造方法 构造器 描述 StringContent()创建一个新的StringContent对象。StringContent(int initialLength)创建一个新的StringContent对象,并指定初始大小。 
-  
             
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 PositioncreatePosition(int offset)在内容中创建一个位置,以便在内容发生变化时跟踪更改。voidgetChars(int where, int len, Segment chars)检索内容的一部分。protected VectorgetPositionsInRange(Vector v, int offset, int length)返回包含位置的UndoPosRef实例的Vector,范围为offset至offset+length。StringgetString(int where, int len)检索内容的一部分。UndoableEditinsertString(int where, String str)在内容中插入字符串。intlength()返回内容的长度。UndoableEditremove(int where, int nitems)删除部分内容。protected voidupdateUndoPositions(Vector positions)重置positions所有UndoPosRef实例的positions。 
 -  
             
 
-  
        
       
-  
             
方法详细信息
-  
length
public int length()
返回内容的长度。- Specified by:
 -  
              
length在界面AbstractDocument.Content - 结果
 - 长度> = 1
 - 另请参见:
 -  
              
AbstractDocument.Content.length() 
 
-  
insertString
public UndoableEdit insertString(int where, String str) throws BadLocationException
在内容中插入字符串。- Specified by:
 -  
              
insertString在界面AbstractDocument.Content - 参数
 -  
              
where- 起始位置> = 0 && <length() -  
              
str- 要插入的非null字符串 - 结果
 - 用于撤消的UndoableEdit对象
 - 异常
 -  
              
BadLocationException- 如果指定的位置无效 - 另请参见:
 -  
              
AbstractDocument.Content.insertString(int, java.lang.String) 
 
-  
remove
public UndoableEdit remove(int where, int nitems) throws BadLocationException
删除部分内容。 其中+ nitems必须是<length()。- Specified by:
 -  
              
remove在界面AbstractDocument.Content - 参数
 -  
              
where- 起始位置> = 0 -  
              
nitems- 要删除的字符数> = 0 - 结果
 - 用于撤消的UndoableEdit对象
 - 异常
 -  
              
BadLocationException- 如果指定的位置无效 - 另请参见:
 -  
              
AbstractDocument.Content.remove(int, int) 
 
-  
getString
public String getString(int where, int len) throws BadLocationException
检索内容的一部分。 其中+ len必须<= length()。- Specified by:
 -  
              
getString在界面AbstractDocument.Content - 参数
 -  
              
where- 起始位置> = 0 -  
              
len- 要检索的长度> = 0 - 结果
 - 表示内容的字符串; 可能是空的
 - 异常
 -  
              
BadLocationException- 如果指定的位置无效 - 另请参见:
 -  
              
AbstractDocument.Content.getString(int, int) 
 
-  
getChars
public void getChars(int where, int len, Segment chars) throws BadLocationException检索内容的一部分。 其中+ len必须<= length()- Specified by:
 -  
              
getChars在界面AbstractDocument.Content - 参数
 -  
              
where- 起始位置> = 0 -  
              
len- 要检索的字符数> = 0 -  
              
chars- 要返回字符的Segment对象 - 异常
 -  
              
BadLocationException- 如果指定的位置无效 - 另请参见:
 -  
              
AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment) 
 
-  
createPosition
public Position createPosition(int offset) throws BadLocationException
在内容中创建一个位置,以便在内容发生变化时跟踪更改。- Specified by:
 -  
              
createPosition在界面AbstractDocument.Content - 参数
 -  
              
offset- 为> = 0创建位置的偏移量 - 结果
 - 这个职位
 - 异常
 -  
              
BadLocationException- 如果指定的位置无效 
 
-  
getPositionsInRange
protected Vector getPositionsInRange(Vector v, int offset, int length)
返回包含位置的UndoPosRef实例的Vector,范围为offset到offset+length。 如果v不为空,则匹配的位置放在那里。 返回带有结果位置的向量。这适用于内部使用,并且通常对子类不感兴趣。
- 参数
 -  
              
v- 要使用的Vector,在null上创建一个新的 -  
              
offset- 起始偏移量> = 0 -  
              
length- 长度> = 0 - 结果
 - 实例集
 
 
-  
updateUndoPositions
protected void updateUndoPositions(Vector positions)
重置positions所有UndoPosRef实例的positions。这适用于内部使用,并且通常对子类不感兴趣。
- 参数
 -  
              
positions- 实例的位置 
 
 -  
 
 -