- java.lang.Object
- 
- javax.swing.text.StyleConstants
 
- 
- Direct Known Subclasses:
- StyleConstants.CharacterConstants,- StyleConstants.ColorConstants,- StyleConstants.FontConstants,- StyleConstants.ParagraphConstants
 
 public class StyleConstants extends Object 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.  
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classStyleConstants.CharacterConstantsThis is a typesafe enumeration of the well-known attributes that contribute to a character style.static classStyleConstants.ColorConstantsThis is a typesafe enumeration of the well-known attributes that contribute to a color.static classStyleConstants.FontConstantsThis is a typesafe enumeration of the well-known attributes that contribute to a font.static classStyleConstants.ParagraphConstantsThis is a typesafe enumeration of the well-known attributes that contribute to a paragraph style.
 - 
Field SummaryFields Modifier and Type Field Description static intALIGN_CENTERA possible value for paragraph alignment.static intALIGN_JUSTIFIEDA possible value for paragraph alignment.static intALIGN_LEFTA possible value for paragraph alignment.static intALIGN_RIGHTA possible value for paragraph alignment.static ObjectAlignmentAlignment for the paragraph.static ObjectBackgroundName of the background color attribute.static ObjectBidiLevelBidirectional level of a character as assigned by the Unicode bidi algorithm.static ObjectBoldName of the bold attribute.static ObjectComponentAttributeName of the component attribute.static StringComponentElementNameName of elements used to represent components.static ObjectComposedTextAttributeName of the input method composed text attribute.static ObjectFamilyName of the font family.static ObjectFirstLineIndentThe amount of space to indent the first line of the paragraph.static ObjectFontFamilyName of the font family.static ObjectFontSizeName of the font size.static ObjectForegroundName of the foreground color attribute.static ObjectIconAttributeName of the icon attribute.static StringIconElementNameName of elements used to represent icons.static ObjectItalicName of the italic attribute.static ObjectLeftIndentThe amount to indent the left side of the paragraph.static ObjectLineSpacingThe amount of space between lines of the paragraph.static ObjectModelAttributeAttribute used to identify the model for embedded objects that have a model view separation.static ObjectNameAttributeAttribute name used to name the collection of attributes.static ObjectOrientationOrientation for a paragraph.static ObjectResolveAttributeAttribute name used to identify the resolving parent set of attributes, if one is defined.static ObjectRightIndentThe amount to indent the right side of the paragraph.static ObjectSizeName of the font size.static ObjectSpaceAboveThe amount of space above the paragraph.static ObjectSpaceBelowThe amount of space below the paragraph.static ObjectStrikeThroughName of the Strikethrough attribute.static ObjectSubscriptName of the Subscript attribute.static ObjectSuperscriptName of the Superscript attribute.static ObjectTabSetTabSet for the paragraph, type is a TabSet containing TabStops.static ObjectUnderlineName of the underline attribute.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intgetAlignment(AttributeSet a)Gets the alignment setting.static ColorgetBackground(AttributeSet a)Gets the background color setting from the attribute list.static intgetBidiLevel(AttributeSet a)Gets the BidiLevel setting.static ComponentgetComponent(AttributeSet a)Gets the component setting from the attribute list.static floatgetFirstLineIndent(AttributeSet a)Gets the first line indent setting.static StringgetFontFamily(AttributeSet a)Gets the font family setting from the attribute list.static intgetFontSize(AttributeSet a)Gets the font size setting from the attribute list.static ColorgetForeground(AttributeSet a)Gets the foreground color setting from the attribute list.static IcongetIcon(AttributeSet a)Gets the icon setting from the attribute list.static floatgetLeftIndent(AttributeSet a)Gets the left indent setting.static floatgetLineSpacing(AttributeSet a)Gets the line spacing setting.static floatgetRightIndent(AttributeSet a)Gets the right indent setting.static floatgetSpaceAbove(AttributeSet a)Gets the space above setting.static floatgetSpaceBelow(AttributeSet a)Gets the space below setting.static TabSetgetTabSet(AttributeSet a)Gets the TabSet.static booleanisBold(AttributeSet a)Checks whether the bold attribute is set.static booleanisItalic(AttributeSet a)Checks whether the italic attribute is set.static booleanisStrikeThrough(AttributeSet a)Checks whether the strikethrough attribute is set.static booleanisSubscript(AttributeSet a)Checks whether the subscript attribute is set.static booleanisSuperscript(AttributeSet a)Checks whether the superscript attribute is set.static booleanisUnderline(AttributeSet a)Checks whether the underline attribute is set.static voidsetAlignment(MutableAttributeSet a, int align)Sets alignment.static voidsetBackground(MutableAttributeSet a, Color fg)Sets the background color.static voidsetBidiLevel(MutableAttributeSet a, int o)Sets the BidiLevel.static voidsetBold(MutableAttributeSet a, boolean b)Sets the bold attribute.static voidsetComponent(MutableAttributeSet a, Component c)Sets the component attribute.static voidsetFirstLineIndent(MutableAttributeSet a, float i)Sets the first line indent.static voidsetFontFamily(MutableAttributeSet a, String fam)Sets the font attribute.static voidsetFontSize(MutableAttributeSet a, int s)Sets the font size attribute.static voidsetForeground(MutableAttributeSet a, Color fg)Sets the foreground color.static voidsetIcon(MutableAttributeSet a, Icon c)Sets the icon attribute.static voidsetItalic(MutableAttributeSet a, boolean b)Sets the italic attribute.static voidsetLeftIndent(MutableAttributeSet a, float i)Sets left indent.static voidsetLineSpacing(MutableAttributeSet a, float i)Sets line spacing.static voidsetRightIndent(MutableAttributeSet a, float i)Sets right indent.static voidsetSpaceAbove(MutableAttributeSet a, float i)Sets space above.static voidsetSpaceBelow(MutableAttributeSet a, float i)Sets space below.static voidsetStrikeThrough(MutableAttributeSet a, boolean b)Sets the strikethrough attribute.static voidsetSubscript(MutableAttributeSet a, boolean b)Sets the subscript attribute.static voidsetSuperscript(MutableAttributeSet a, boolean b)Sets the superscript attribute.static voidsetTabSet(MutableAttributeSet a, TabSet tabs)Sets the TabSet.static voidsetUnderline(MutableAttributeSet a, boolean b)Sets the underline attribute.StringtoString()Returns the string representation.
 
- 
- 
- 
Field Detail- 
ComponentElementNamepublic static final String ComponentElementName Name of elements used to represent components.- See Also:
- Constant Field Values
 
 - 
IconElementNamepublic static final String IconElementName Name of elements used to represent icons.- See Also:
- Constant Field Values
 
 - 
NameAttributepublic static final Object NameAttribute Attribute name used to name the collection of attributes.
 - 
ResolveAttributepublic static final Object ResolveAttribute Attribute name used to identify the resolving parent set of attributes, if one is defined.
 - 
ModelAttributepublic static final Object ModelAttribute Attribute used to identify the model for embedded objects that have a model view separation.
 - 
BidiLevelpublic static final Object BidiLevel Bidirectional level of a character as assigned by the Unicode bidi algorithm.
 - 
FontFamilypublic static final Object FontFamily Name of the font family.
 - 
Familypublic static final Object Family Name of the font family.- Since:
- 1.5
 
 - 
FontSizepublic static final Object FontSize Name of the font size.
 - 
Sizepublic static final Object Size Name of the font size.- Since:
- 1.5
 
 - 
Boldpublic static final Object Bold Name of the bold attribute.
 - 
Italicpublic static final Object Italic Name of the italic attribute.
 - 
Underlinepublic static final Object Underline Name of the underline attribute.
 - 
StrikeThroughpublic static final Object StrikeThrough Name of the Strikethrough attribute.
 - 
Superscriptpublic static final Object Superscript Name of the Superscript attribute.
 - 
Subscriptpublic static final Object Subscript Name of the Subscript attribute.
 - 
Foregroundpublic static final Object Foreground Name of the foreground color attribute.
 - 
Backgroundpublic static final Object Background Name of the background color attribute.
 - 
ComponentAttributepublic static final Object ComponentAttribute Name of the component attribute.
 - 
IconAttributepublic static final Object IconAttribute Name of the icon attribute.
 - 
ComposedTextAttributepublic 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.
 - 
FirstLineIndentpublic 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.
 - 
LeftIndentpublic static final Object LeftIndent The amount to indent the left side of the paragraph. Type is float and specifies the size in points.
 - 
RightIndentpublic static final Object RightIndent The amount to indent the right side of the paragraph. Type is float and specifies the size in points.
 - 
LineSpacingpublic 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
 - 
SpaceAbovepublic static final Object SpaceAbove The amount of space above the paragraph. Type is float and specifies the size in points.
 - 
SpaceBelowpublic static final Object SpaceBelow The amount of space below the paragraph. Type is float and specifies the size in points.
 - 
Alignmentpublic static final Object Alignment Alignment for the paragraph. The type is Integer. Valid values are:- ALIGN_LEFT
- ALIGN_RIGHT
- ALIGN_CENTER
- ALIGN_JUSTIFED
 
 - 
TabSetpublic static final Object TabSet TabSet for the paragraph, type is a TabSet containing TabStops.
 - 
Orientationpublic static final Object Orientation Orientation for a paragraph.
 - 
ALIGN_LEFTpublic 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:
- Constant Field Values
 
 - 
ALIGN_CENTERpublic 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:
- Constant Field Values
 
 - 
ALIGN_RIGHTpublic 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:
- Constant Field Values
 
 - 
ALIGN_JUSTIFIEDpublic 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:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
toStringpublic String toString() Returns the string representation.
 - 
getBidiLevelpublic static int getBidiLevel(AttributeSet a) Gets the BidiLevel setting.- Parameters:
- a- the attribute set
- Returns:
- the value
 
 - 
setBidiLevelpublic static void setBidiLevel(MutableAttributeSet a, int o) Sets the BidiLevel.- Parameters:
- a- the attribute set
- o- the bidi level value
 
 - 
getComponentpublic static Component getComponent(AttributeSet a) Gets the component setting from the attribute list.- Parameters:
- a- the attribute set
- Returns:
- the component, null if none
 
 - 
setComponentpublic static void setComponent(MutableAttributeSet a, Component c) Sets the component attribute.- Parameters:
- a- the attribute set
- c- the component
 
 - 
getIconpublic static Icon getIcon(AttributeSet a) Gets the icon setting from the attribute list.- Parameters:
- a- the attribute set
- Returns:
- the icon, null if none
 
 - 
setIconpublic static void setIcon(MutableAttributeSet a, Icon c) Sets the icon attribute.- Parameters:
- a- the attribute set
- c- the icon
 
 - 
getFontFamilypublic 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
 
 - 
setFontFamilypublic static void setFontFamily(MutableAttributeSet a, String fam) Sets the font attribute.- Parameters:
- a- the attribute set
- fam- the font
 
 - 
getFontSizepublic 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
 
 - 
setFontSizepublic static void setFontSize(MutableAttributeSet a, int s) Sets the font size attribute.- Parameters:
- a- the attribute set
- s- the font size
 
 - 
isBoldpublic static boolean isBold(AttributeSet a) Checks whether the bold attribute is set.- Parameters:
- a- the attribute set
- Returns:
- true if set else false
 
 - 
setBoldpublic static void setBold(MutableAttributeSet a, boolean b) Sets the bold attribute.- Parameters:
- a- the attribute set
- b- specifies true/false for setting the attribute
 
 - 
isItalicpublic static boolean isItalic(AttributeSet a) Checks whether the italic attribute is set.- Parameters:
- a- the attribute set
- Returns:
- true if set else false
 
 - 
setItalicpublic static void setItalic(MutableAttributeSet a, boolean b) Sets the italic attribute.- Parameters:
- a- the attribute set
- b- specifies true/false for setting the attribute
 
 - 
isUnderlinepublic static boolean isUnderline(AttributeSet a) Checks whether the underline attribute is set.- Parameters:
- a- the attribute set
- Returns:
- true if set else false
 
 - 
isStrikeThroughpublic static boolean isStrikeThrough(AttributeSet a) Checks whether the strikethrough attribute is set.- Parameters:
- a- the attribute set
- Returns:
- true if set else false
 
 - 
isSuperscriptpublic static boolean isSuperscript(AttributeSet a) Checks whether the superscript attribute is set.- Parameters:
- a- the attribute set
- Returns:
- true if set else false
 
 - 
isSubscriptpublic static boolean isSubscript(AttributeSet a) Checks whether the subscript attribute is set.- Parameters:
- a- the attribute set
- Returns:
- true if set else false
 
 - 
setUnderlinepublic static void setUnderline(MutableAttributeSet a, boolean b) Sets the underline attribute.- Parameters:
- a- the attribute set
- b- specifies true/false for setting the attribute
 
 - 
setStrikeThroughpublic static void setStrikeThrough(MutableAttributeSet a, boolean b) Sets the strikethrough attribute.- Parameters:
- a- the attribute set
- b- specifies true/false for setting the attribute
 
 - 
setSuperscriptpublic static void setSuperscript(MutableAttributeSet a, boolean b) Sets the superscript attribute.- Parameters:
- a- the attribute set
- b- specifies true/false for setting the attribute
 
 - 
setSubscriptpublic static void setSubscript(MutableAttributeSet a, boolean b) Sets the subscript attribute.- Parameters:
- a- the attribute set
- b- specifies true/false for setting the attribute
 
 - 
getForegroundpublic 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
 
 - 
setForegroundpublic static void setForeground(MutableAttributeSet a, Color fg) Sets the foreground color.- Parameters:
- a- the attribute set
- fg- the color
 
 - 
getBackgroundpublic 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
 
 - 
setBackgroundpublic static void setBackground(MutableAttributeSet a, Color fg) Sets the background color.- Parameters:
- a- the attribute set
- fg- the color
 
 - 
getFirstLineIndentpublic static float getFirstLineIndent(AttributeSet a) Gets the first line indent setting.- Parameters:
- a- the attribute set
- Returns:
- the value, 0 if not set
 
 - 
setFirstLineIndentpublic static void setFirstLineIndent(MutableAttributeSet a, float i) Sets the first line indent.- Parameters:
- a- the attribute set
- i- the value
 
 - 
getRightIndentpublic static float getRightIndent(AttributeSet a) Gets the right indent setting.- Parameters:
- a- the attribute set
- Returns:
- the value, 0 if not set
 
 - 
setRightIndentpublic static void setRightIndent(MutableAttributeSet a, float i) Sets right indent.- Parameters:
- a- the attribute set
- i- the value
 
 - 
getLeftIndentpublic static float getLeftIndent(AttributeSet a) Gets the left indent setting.- Parameters:
- a- the attribute set
- Returns:
- the value, 0 if not set
 
 - 
setLeftIndentpublic static void setLeftIndent(MutableAttributeSet a, float i) Sets left indent.- Parameters:
- a- the attribute set
- i- the value
 
 - 
getLineSpacingpublic static float getLineSpacing(AttributeSet a) Gets the line spacing setting.- Parameters:
- a- the attribute set
- Returns:
- the value, 0 if not set
 
 - 
setLineSpacingpublic static void setLineSpacing(MutableAttributeSet a, float i) Sets line spacing.- Parameters:
- a- the attribute set
- i- the value
 
 - 
getSpaceAbovepublic static float getSpaceAbove(AttributeSet a) Gets the space above setting.- Parameters:
- a- the attribute set
- Returns:
- the value, 0 if not set
 
 - 
setSpaceAbovepublic static void setSpaceAbove(MutableAttributeSet a, float i) Sets space above.- Parameters:
- a- the attribute set
- i- the value
 
 - 
getSpaceBelowpublic static float getSpaceBelow(AttributeSet a) Gets the space below setting.- Parameters:
- a- the attribute set
- Returns:
- the value, 0 if not set
 
 - 
setSpaceBelowpublic static void setSpaceBelow(MutableAttributeSet a, float i) Sets space below.- Parameters:
- a- the attribute set
- i- the value
 
 - 
getAlignmentpublic static int getAlignment(AttributeSet a) Gets the alignment setting.- Parameters:
- a- the attribute set
- Returns:
- the value StyleConstants.ALIGN_LEFTif not set
 
 - 
setAlignmentpublic static void setAlignment(MutableAttributeSet a, int align) Sets alignment.- Parameters:
- a- the attribute set
- align- the alignment value
 
 - 
getTabSetpublic static TabSet getTabSet(AttributeSet a) Gets the TabSet.- Parameters:
- a- the attribute set
- Returns:
- the TabSet
 
 - 
setTabSetpublic static void setTabSet(MutableAttributeSet a, TabSet tabs) Sets the TabSet.- Parameters:
- a- the attribute set.
- tabs- the TabSet
 
 
- 
 
-