Class StyleConstants

java.lang.Object
javax.swing.text.StyleConstants
Direct Known Subclasses:
StyleConstants.CharacterConstants, StyleConstants.ColorConstants, StyleConstants.FontConstants, StyleConstants.ParagraphConstants

A collection of well known or common attribute keys and methods to apply to an AttributeSet or MutableAttributeSet to get/set the properties in a typesafe manner.

The paragraph attributes form the definition of a paragraph to be rendered. All sizes are specified in points (such as found in postscript), a device independent measure.

Diagram shows SpaceAbove, FirstLineIndent, LeftIndent, RightIndent,
      and SpaceBelow a paragraph.

Sealed Class Hierarchy Graph:
Sealed class hierarchy graph for StyleConstantsSealed class hierarchy graph for StyleConstants
  • Field Details Link icon

    • ComponentElementName Link icon

      public static final String ComponentElementName
      Name of elements used to represent components.
      See Also:
    • IconElementName Link icon

      public static final String IconElementName
      Name of elements used to represent icons.
      See Also:
    • NameAttribute Link icon

      public static final Object NameAttribute
      Attribute name used to name the collection of attributes.
    • ResolveAttribute Link icon

      public static final Object ResolveAttribute
      Attribute name used to identify the resolving parent set of attributes, if one is defined.
    • ModelAttribute Link icon

      public static final Object ModelAttribute
      Attribute used to identify the model for embedded objects that have a model view separation.
    • BidiLevel Link icon

      public static final Object BidiLevel
      Bidirectional level of a character as assigned by the Unicode bidi algorithm.
    • FontFamily Link icon

      public static final Object FontFamily
      Name of the font family.
    • Family Link icon

      public static final Object Family
      Name of the font family.
      Since:
      1.5
    • FontSize Link icon

      public static final Object FontSize
      Name of the font size.
    • Size Link icon

      public static final Object Size
      Name of the font size.
      Since:
      1.5
    • Bold Link icon

      public static final Object Bold
      Name of the bold attribute.
    • Italic Link icon

      public static final Object Italic
      Name of the italic attribute.
    • Underline Link icon

      public static final Object Underline
      Name of the underline attribute.
    • StrikeThrough Link icon

      public static final Object StrikeThrough
      Name of the Strikethrough attribute.
    • Superscript Link icon

      public static final Object Superscript
      Name of the Superscript attribute.
    • Subscript Link icon

      public static final Object Subscript
      Name of the Subscript attribute.
    • Foreground Link icon

      public static final Object Foreground
      Name of the foreground color attribute.
    • Background Link icon

      public static final Object Background
      Name of the background color attribute.
    • ComponentAttribute Link icon

      public static final Object ComponentAttribute
      Name of the component attribute.
    • IconAttribute Link icon

      public static final Object IconAttribute
      Name of the icon attribute.
    • ComposedTextAttribute Link icon

      public static final Object ComposedTextAttribute
      Name of the input method composed text attribute. The value of this attribute is an instance of AttributedString which represents the composed text.
    • FirstLineIndent Link icon

      public static final Object FirstLineIndent
      The amount of space to indent the first line of the paragraph. This value may be negative to offset in the reverse direction. The type is Float and specifies the size of the space in points.
    • LeftIndent Link icon

      public static final Object LeftIndent
      The amount to indent the left side of the paragraph. Type is float and specifies the size in points.
    • RightIndent Link icon

      public static final Object RightIndent
      The amount to indent the right side of the paragraph. Type is float and specifies the size in points.
    • LineSpacing Link icon

      public static final Object LineSpacing
      The amount of space between lines of the paragraph. Type is float and specifies the size as a factor of the line height
    • SpaceAbove Link icon

      public static final Object SpaceAbove
      The amount of space above the paragraph. Type is float and specifies the size in points.
    • SpaceBelow Link icon

      public static final Object SpaceBelow
      The amount of space below the paragraph. Type is float and specifies the size in points.
    • Alignment Link icon

      public static final Object Alignment
      Alignment for the paragraph. The type is Integer. Valid values are:
      • ALIGN_LEFT
      • ALIGN_RIGHT
      • ALIGN_CENTER
      • ALIGN_JUSTIFED
    • TabSet Link icon

      public static final Object TabSet
      TabSet for the paragraph, type is a TabSet containing TabStops.
    • Orientation Link icon

      public static final Object Orientation
      Orientation for a paragraph.
    • ALIGN_LEFT Link icon

      public static final int ALIGN_LEFT
      A possible value for paragraph alignment. This specifies that the text is aligned to the left indent and extra whitespace should be placed on the right.
      See Also:
    • ALIGN_CENTER Link icon

      public static final int ALIGN_CENTER
      A possible value for paragraph alignment. This specifies that the text is aligned to the center and extra whitespace should be placed equally on the left and right.
      See Also:
    • ALIGN_RIGHT Link icon

      public static final int ALIGN_RIGHT
      A possible value for paragraph alignment. This specifies that the text is aligned to the right indent and extra whitespace should be placed on the left.
      See Also:
    • ALIGN_JUSTIFIED Link icon

      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 Link icon

    • toString Link icon

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

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

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

      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 Link icon

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

      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 Link icon

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

      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 Link icon

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

      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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

      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 Link icon

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

      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 Link icon

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

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

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

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

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

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

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

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

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

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

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

      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 Link icon

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

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

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