java.lang.Objectjavax.swing.text.View
javax.swing.text.GlyphView
javax.swing.text.LabelView
public class LabelView
LabelView 是一个样式化文本存储块,它表示映射文本模型中某个元素的视图。它缓存用于呈现的字符级属性。
| 嵌套类摘要 |
|---|
| 从类 javax.swing.text.GlyphView 继承的嵌套类/接口 |
|---|
GlyphView.GlyphPainter |
| 字段摘要 |
|---|
| 从类 javax.swing.text.View 继承的字段 |
|---|
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS |
| 从接口 javax.swing.SwingConstants 继承的字段 |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| 构造方法摘要 | |
|---|---|
LabelView(Element elem) 构造在元素上包装的新视图。 |
|
| 方法摘要 | |
|---|---|
void |
changedUpdate(DocumentEvent e, Shape a, ViewFactory f) 发出通知,通知文档此视图负责的位置处的属性已更改。 |
Color |
getBackground() 获取用于呈现字形的背景色。 |
Font |
getFont() 获取字形应该以其为依据的字体。 |
protected FontMetrics |
getFontMetrics() 已过时。 FontMetrics 不用于在 JDK 中运行时的字形呈现。 |
Color |
getForeground() 获取用于呈现字形的前景色。 |
boolean |
isStrikeThrough() 确定字形是否应该有删除线。 |
boolean |
isSubscript() 确定字形是否应该呈现为上标。 |
boolean |
isSuperscript() 确定字形是否应该呈现为下标。 |
boolean |
isUnderline() 确定字形是否应加下划线。 |
protected void |
setBackground(Color bg) 设置视图的背景色。 |
protected void |
setPropertiesFromAttributes() 从属性集设置缓存的属性。 |
protected void |
setStrikeThrough(boolean s) 设置视图是否具有删除线。 |
protected void |
setSubscript(boolean s) 设置视图是否有下标。 |
protected void |
setSuperscript(boolean s) 设置视图是否有上标。 |
protected void |
setUnderline(boolean u) 设置视图是否加下划线。 |
| 从类 java.lang.Object 继承的方法 |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 从接口 javax.swing.text.TabableView 继承的方法 |
|---|
getPartialSpan, getTabbedSpan |
| 构造方法详细信息 |
|---|
public LabelView(Element elem)
elem - 元素
| 方法详细信息 |
|---|
protected void setUnderline(boolean u)
u - 如果视图加下划线,则为 true;否则为 false
isUnderline()
protected void setStrikeThrough(boolean s)
s - 如果视图有删除线,则为 true;否则为 false
isStrikeThrough()
protected void setSuperscript(boolean s)
s - 如果视图有上标,则为 true;否则为 false
isSuperscript()
protected void setSubscript(boolean s)
s - 如果视图有下标,则为 true;否则为 false
isSubscript()
protected void setBackground(Color bg)
View 的一部分调用。如果需要自定义背景色,则应重写
setPropertiesFromAttributes 并调用此方法。null 值指示不应呈现背景,这样将始终显示父级
View 的背景。
bg - 背景色,或 null
setPropertiesFromAttributes()
protected void setPropertiesFromAttributes()
@Deprecated protected FontMetrics getFontMetrics()
FontMetrics。
public Color getBackground()
null。
GlyphView 中的
getBackground
public Color getForeground()
null。
GlyphView 中的
getForeground
public Font getFont()
public boolean isUnderline()
当请求此属性时,LabelView 会重新将其状态与 Element 的 AttributeSet 属性同步。如果 Element 的 AttributeSet 没有此属性设置,则它将转换为 false。
GlyphView 中的
isUnderline
underline 属性的值
public boolean isStrikeThrough()
strikeThrough 属性。
当请求此属性时,LabelView 会重新将其状态与 Element 的 AttributeSet 属性同步。如果 Element 的 AttributeSet 没有此属性设置,则它将转换为 false。
GlyphView 中的
isStrikeThrough
strikeThrough 属性的值
public boolean isSubscript()
GlyphView 中的
isSubscript
当请求此属性时,LabelView 会重新将其状态与 Element 的 AttributeSet 属性同步。如果 Element 的 AttributeSet 没有此属性设置,则它将转换为 false。
public boolean isSuperscript()
当请求此属性时,LabelView 会重新将其状态与 Element 的 AttributeSet 属性同步。如果 Element 的 AttributeSet 没有此属性设置,则它将转换为 false。
GlyphView 中的
isSuperscript
superscript 属性的值
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
GlyphView 中的
changedUpdate
e - 来自相关文档的更改信息
a - 视图的当前分配区域
f - 用于重建的工厂(如果该视图有子级)
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)