- java.lang.Object
-
- javax.swing.text.AbstractDocument.AbstractElement
-
- javax.swing.text.AbstractDocument.BranchElement
-
- All Implemented Interfaces:
-
Serializable,AttributeSet,Element,MutableAttributeSet,TreeNode
- Enclosing class:
- AbstractDocument
public class AbstractDocument.BranchElement extends AbstractDocument.AbstractElement
实现一个包含其他元素的复合元素。警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,支持所有JavaBeans的长期存储已被添加到
java.beans包中。 请参阅XMLEncoder。- 另请参见:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
-
-
Field Summary
-
Fields inherited from interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
-
-
构造方法摘要
构造方法 Constructor 描述 BranchElement(Element parent, AttributeSet a)构造最初不包含子项的复合元素。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 Enumeration<TreeNode>children()以Enumeration返回接收者的Enumeration。booleangetAllowsChildren()如果接收器允许孩子,则返回true。ElementgetElement(int index)获取一个子元素。intgetElementCount()获取元素的子元素数。intgetElementIndex(int offset)获取最接近给定模型偏移量的子元素索引。intgetEndOffset()获取元素模型中的结束偏移量。StringgetName()获取元素名称。intgetStartOffset()获取元素模型中的起始偏移量。booleanisLeaf()检查元素是否是叶子。ElementpositionToElement(int pos)获取包含给定模型位置的子元素。voidreplace(int offset, int length, Element[] elems)用新的元素集替换内容。StringtoString()将元素转换为字符串。-
Methods inherited from class javax.swing.text.AbstractDocument.AbstractElement
addAttribute, addAttributes, containsAttribute, containsAttributes, copyAttributes, dump, getAttribute, getAttributeCount, getAttributeNames, getAttributes, getChildAt, getChildCount, getDocument, getIndex, getParent, getParentElement, getResolveParent, isDefined, isEqual, removeAttribute, removeAttributes, removeAttributes, setResolveParent
-
-
-
-
构造方法详细信息
-
BranchElement
public BranchElement(Element parent, AttributeSet a)
构造最初不包含子项的复合元素。- 参数
-
parent- 父元素 -
a- 元素的属性 - 从以下版本开始:
- 1.4
-
-
方法详细信息
-
positionToElement
public Element positionToElement(int pos)
获取包含给定模型位置的子元素。- 参数
-
pos- 位置> = 0 - 结果
- 元素,如果没有,则为null
-
replace
public void replace(int offset, int length, Element[] elems)用新的元素集替换内容。- 参数
-
offset- 起始偏移量> = 0 -
length- 要替换的长度> = 0 -
elems- 新元素
-
getName
public String getName()
获取元素名称。- Specified by:
-
getName接口Element - 重写:
-
getName在AbstractDocument.AbstractElement - 结果
- 元素名称
-
getStartOffset
public int getStartOffset()
获取元素模型中的起始偏移量。- Specified by:
-
getStartOffset在接口Element - Specified by:
-
getStartOffset在AbstractDocument.AbstractElement - 结果
- offset> = 0
- 另请参见:
-
Document,AbstractDocument
-
getEndOffset
public int getEndOffset()
获取元素模型中的结束偏移量。- Specified by:
-
getEndOffset在接口Element - Specified by:
-
getEndOffset在AbstractDocument.AbstractElement - 结果
- offset> = 0
- 异常
-
NullPointerException- 如果这个元素没有孩子 - 另请参见:
-
Document,AbstractDocument
-
getElement
public Element getElement(int index)
获取一个子元素。- Specified by:
-
getElement在接口Element - Specified by:
-
getElement在AbstractDocument.AbstractElement - 参数
-
index- 子索引> = 0 && <getElementCount() - 结果
- 子元素,如果没有,则为null
-
getElementCount
public int getElementCount()
获取元素的子元素数。- Specified by:
-
getElementCount在接口Element - Specified by:
-
getElementCount在类AbstractDocument.AbstractElement - 结果
- 孩子数> = 0
-
getElementIndex
public int getElementIndex(int offset)
获取最接近给定模型偏移量的子元素索引。- Specified by:
-
getElementIndex在接口Element - Specified by:
-
getElementIndex在AbstractDocument.AbstractElement - 参数
-
offset- offset> = 0 - 结果
- 元素索引> = 0
-
isLeaf
public boolean isLeaf()
检查元素是否是叶子。
-
getAllowsChildren
public boolean getAllowsChildren()
如果接收器允许孩子,则返回true。- Specified by:
-
getAllowsChildren在接口TreeNode - Specified by:
-
getAllowsChildren在AbstractDocument.AbstractElement - 结果
- 如果接收器允许孩子,则为true,否则为false
-
children
public Enumeration<TreeNode> children()
以Enumeration返回接收者的Enumeration。- Specified by:
-
children接口TreeNode - Specified by:
-
children在AbstractDocument.AbstractElement - 结果
- 接收者的孩子
-
-