Module java.desktop
Package javax.swing.text

Class StyleConstants

java.lang.Object
javax.swing.text.StyleConstants
直接已知的子类:
StyleConstants.CharacterConstants, StyleConstants.ColorConstants, StyleConstants.FontConstants, StyleConstants.ParagraphConstants

一组众所周知或常见的属性键和方法,用于以类型安全的方式应用于AttributeSet或MutableAttributeSet以获取/设置属性。

段落属性形成要呈现的段落的定义。所有大小都以点(如在后置脚本中找到的)指定,这是一种设备无关的度量。

图表显示段落上方、首行缩进、左缩进、右缩进和段落下方的空间。

封闭类层次结构图:
StyleConstants的封闭类层次结构图StyleConstants的封闭类层次结构图
  • Field Details

    • ComponentElementName

      public static final String ComponentElementName
      用于表示组件的元素的名称。
      参见:
    • IconElementName

      public static final String IconElementName
      用于表示图标的元素的名称。
      参见:
    • NameAttribute

      public static final Object NameAttribute
      用于命名属性集合的属性名称。
    • ResolveAttribute

      public static final Object ResolveAttribute
      用于标识解析父属性集合的属性名称,如果已定义。
    • ModelAttribute

      public static final Object ModelAttribute
      用于标识具有模型视图分离的嵌入对象的模型的属性。
    • BidiLevel

      public static final Object BidiLevel
      字符的双向级别,由Unicode双向算法分配。
    • FontFamily

      public static final Object FontFamily
      字体系列的名称。
    • Family

      public static final Object Family
      字体系列的名称。
      自版本:
      1.5
    • FontSize

      public static final Object FontSize
      字体大小的名称。
    • Size

      public static final Object Size
      字体大小的名称。
      自版本:
      1.5
    • Bold

      public static final Object Bold
      粗体属性的名称。
    • Italic

      public static final Object Italic
      斜体属性的名称。
    • Underline

      public static final Object Underline
      下划线属性的名称。
    • StrikeThrough

      public static final Object StrikeThrough
      删除线属性的名称。
    • Superscript

      public static final Object Superscript
      上标属性的名称。
    • Subscript

      public static final Object Subscript
      下标属性的名称。
    • Foreground

      public static final Object Foreground
      前景颜色属性的名称。
    • Background

      public static final Object Background
      背景颜色属性的名称。
    • ComponentAttribute

      public static final Object ComponentAttribute
      组件属性的名称。
    • IconAttribute

      public static final Object IconAttribute
      图标属性的名称。
    • ComposedTextAttribute

      public static final Object ComposedTextAttribute
      用于表示输入法组合文本的属性名称。该属性的值是一个AttributedString的实例,表示组合文本。
    • FirstLineIndent

      public static final Object FirstLineIndent
      段落首行缩进的空间量。此值可能为负,以在相反方向上进行偏移。类型为Float,指定点数大小的空间。
    • LeftIndent

      public static final Object LeftIndent
      段落左侧缩进的量。类型为浮点数,指定点数大小。
    • RightIndent

      public static final Object RightIndent
      段落右侧缩进的量。类型为浮点数,指定点数大小。
    • LineSpacing

      public static final Object LineSpacing
      段落行之间的空间量。类型为浮点数,指定大小作为行高的因子。
    • SpaceAbove

      public static final Object SpaceAbove
      段落上方的空间量。类型为浮点数,指定点数大小。
    • SpaceBelow

      public static final Object SpaceBelow
      段落下方的空间量。类型为浮点数,指定点数大小。
    • Alignment

      public static final Object Alignment
      段落的对齐方式。类型为整数。有效值为:
      • ALIGN_LEFT
      • ALIGN_RIGHT
      • ALIGN_CENTER
      • ALIGN_JUSTIFED
    • TabSet

      public static final Object TabSet
      段落的TabSet,类型为包含TabStops的TabSet。
    • Orientation

      public static final Object Orientation
      段落的方向。
    • ALIGN_LEFT

      public static final int ALIGN_LEFT
      段落对齐的可能值。指定文本对齐到左缩进,额外的空白应放在右侧。
      参见:
    • ALIGN_CENTER

      public static final int ALIGN_CENTER
      段落对齐的可能值。指定文本对齐到中心,额外的空白应均匀放置在左右两侧。
      参见:
    • ALIGN_RIGHT

      public static final int ALIGN_RIGHT
      段落对齐的可能值。指定文本对齐到右缩进,额外的空白应放在左侧。
      See Also:
    • ALIGN_JUSTIFIED

      public static final int ALIGN_JUSTIFIED
      A possible value for paragraph alignment. This specifies that extra whitespace should be spread out through the rows of the paragraph with the text lined up with the left and right indent except on the last line which should be aligned to the left.
      See Also:
  • Method Details

    • toString

      public String toString()
      Returns the string representation.
      Overrides:
      toString in class Object
      Returns:
      the string
    • getBidiLevel

      public static int getBidiLevel(AttributeSet a)
      Gets the BidiLevel setting.
      Parameters:
      a - the attribute set
      Returns:
      the value
    • setBidiLevel

      public static void setBidiLevel(MutableAttributeSet a, int o)
      Sets the BidiLevel.
      Parameters:
      a - the attribute set
      o - the bidi level value
    • getComponent

      public static Component getComponent(AttributeSet a)
      Gets the component setting from the attribute list.
      Parameters:
      a - the attribute set
      Returns:
      the component, null if none
    • setComponent

      public static void setComponent(MutableAttributeSet a, Component c)
      Sets the component attribute.
      Parameters:
      a - the attribute set
      c - the component
    • getIcon

      public static Icon getIcon(AttributeSet a)
      Gets the icon setting from the attribute list.
      Parameters:
      a - the attribute set
      Returns:
      the icon, null if none
    • setIcon

      public static void setIcon(MutableAttributeSet a, Icon c)
      Sets the icon attribute.
      Parameters:
      a - the attribute set
      c - the icon
    • getFontFamily

      public static String getFontFamily(AttributeSet a)
      Gets the font family setting from the attribute list.
      Parameters:
      a - the attribute set
      Returns:
      the font family, "Monospaced" as the default
    • setFontFamily

      public static void setFontFamily(MutableAttributeSet a, String fam)
      Sets the font attribute.
      Parameters:
      a - the attribute set
      fam - the font
    • getFontSize

      public static int getFontSize(AttributeSet a)
      Gets the font size setting from the attribute list.
      Parameters:
      a - the attribute set
      Returns:
      the font size, 12 as the default
    • setFontSize

      public static void setFontSize(MutableAttributeSet a, int s)
      Sets the font size attribute.
      Parameters:
      a - the attribute set
      s - the font size
    • isBold

      public static boolean isBold(AttributeSet a)
      Checks whether the bold attribute is set.
      Parameters:
      a - the attribute set
      Returns:
      true if set else false
    • setBold

      public static void setBold(MutableAttributeSet a, boolean b)
      Sets the bold attribute.
      Parameters:
      a - the attribute set
      b - specifies true/false for setting the attribute
    • isItalic

      public static boolean isItalic(AttributeSet a)
      Checks whether the italic attribute is set.
      Parameters:
      a - the attribute set
      Returns:
      true if set else false
    • setItalic

      public static void setItalic(MutableAttributeSet a, boolean b)
      Sets the italic attribute.
      Parameters:
      a - the attribute set
      b - specifies true/false for setting the attribute
    • isUnderline

      public static boolean isUnderline(AttributeSet a)
      Checks whether the underline attribute is set.
      Parameters:
      a - the attribute set
      Returns:
      true if set else false
    • isStrikeThrough

      public static boolean isStrikeThrough(AttributeSet a)
      Checks whether the strikethrough attribute is set.
      Parameters:
      a - the attribute set
      Returns:
      true if set else false
    • isSuperscript

      public static boolean isSuperscript(AttributeSet a)
      Checks whether the superscript attribute is set.
      Parameters:
      a - the attribute set
      Returns:
      true if set else false
    • isSubscript

      public static boolean isSubscript(AttributeSet a)
      Checks whether the subscript attribute is set.
      Parameters:
      a - the attribute set
      Returns:
      true if set else false
    • setUnderline

      public static void setUnderline(MutableAttributeSet a, boolean b)
      Sets the underline attribute.
      Parameters:
      a - the attribute set
      b - specifies true/false for setting the attribute
    • setStrikeThrough

      public static void setStrikeThrough(MutableAttributeSet a, boolean b)
      Sets the strikethrough attribute.
      Parameters:
      a - the attribute set
      b - specifies true/false for setting the attribute
    • setSuperscript

      public static void setSuperscript(MutableAttributeSet a, boolean b)
      Sets the superscript attribute.
      Parameters:
      a - the attribute set
      b - specifies true/false for setting the attribute
    • setSubscript

      public static void setSubscript(MutableAttributeSet a, boolean b)
      Sets the subscript attribute.
      Parameters:
      a - the attribute set
      b - specifies true/false for setting the attribute
    • getForeground

      public static Color getForeground(AttributeSet a)
      Gets the foreground color setting from the attribute list.
      Parameters:
      a - the attribute set
      Returns:
      the color, Color.black as the default
    • setForeground

      public static void setForeground(MutableAttributeSet a, Color fg)
      Sets the foreground color.
      Parameters:
      a - the attribute set
      fg - the color
    • getBackground

      public static Color getBackground(AttributeSet a)
      Gets the background color setting from the attribute list.
      Parameters:
      a - the attribute set
      Returns:
      the color, Color.black as the default
    • setBackground

      public static void setBackground(MutableAttributeSet a, Color fg)
      Sets the background color.
      Parameters:
      a - the attribute set
      fg - the color
    • getFirstLineIndent

      public static float getFirstLineIndent(AttributeSet a)
      Gets the first line indent setting.
      Parameters:
      a - the attribute set
      Returns:
      the value, 0 if not set
    • setFirstLineIndent

      public static void setFirstLineIndent(MutableAttributeSet a, float i)
      Sets the first line indent.
      Parameters:
      a - the attribute set
      i - the value
    • getRightIndent

      public static float getRightIndent(AttributeSet a)
      Gets the right indent setting.
      Parameters:
      a - the attribute set
      Returns:
      the value, 0 if not set
    • setRightIndent

      public static void setRightIndent(MutableAttributeSet a, float i)
      Sets right indent.
      Parameters:
      a - the attribute set
      i - the value
    • getLeftIndent

      public static float getLeftIndent(AttributeSet a)
      Gets the left indent setting.
      Parameters:
      a - the attribute set
      Returns:
      the value, 0 if not set
    • setLeftIndent

      public static void setLeftIndent(MutableAttributeSet a, float i)
      Sets left indent.
      Parameters:
      a - the attribute set
      i - the value
    • getLineSpacing

      public static float getLineSpacing(AttributeSet a)
      Gets the line spacing setting.
      Parameters:
      a - the attribute set
      Returns:
      the value, 0 if not set
    • setLineSpacing

      public static void setLineSpacing(MutableAttributeSet a, float i)
      Sets line spacing.
      Parameters:
      a - the attribute set
      i - the value
    • getSpaceAbove

      public static float getSpaceAbove(AttributeSet a)
      Gets the space above setting.
      Parameters:
      a - the attribute set
      Returns:
      the value, 0 if not set
    • setSpaceAbove

      public static void setSpaceAbove(MutableAttributeSet a, float i)
      Sets space above.
      Parameters:
      a - the attribute set
      i - the value
    • getSpaceBelow

      public static float getSpaceBelow(AttributeSet a)
      Gets the space below setting.
      Parameters:
      a - the attribute set
      Returns:
      the value, 0 if not set
    • setSpaceBelow

      public static void setSpaceBelow(MutableAttributeSet a, float i)
      Sets space below.
      Parameters:
      a - the attribute set
      i - the value
    • getAlignment

      public static int getAlignment(AttributeSet a)
      Gets the alignment setting.
      Parameters:
      a - the attribute set
      Returns:
      the value StyleConstants.ALIGN_LEFT if not set
    • setAlignment

      public static void setAlignment(MutableAttributeSet a, int align)
      Sets alignment.
      Parameters:
      a - the attribute set
      align - the alignment value
    • getTabSet

      public static TabSet getTabSet(AttributeSet a)
      Gets the TabSet.
      Parameters:
      a - the attribute set
      Returns:
      the TabSet
    • setTabSet

      public static void setTabSet(MutableAttributeSet a, TabSet tabs)
      Sets the TabSet.
      Parameters:
      a - the attribute set.
      tabs - the TabSet