All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.text.StyleContext
java.lang.Object
|
+----com.sun.java.swing.text.StyleContext
- public class StyleContext
- extends Object
- implements Serializable
A pool of styles and their associated resources. This class determines
the lifetime of a group of resources by being a container that holds
caches for various resources such as font and color that get reused
by the various style definitions. This can be shared by multiple
documents if desired to maximize the sharing of related resources.
-
ComponentElementName
- Name of elements used to represent components.
-
DEFAULT_STYLE
- The name given to the default logical style attached
to paragraphs.
-
IconElementName
- Name of elements used to represent icons.
-
StyleContext()
-
-
addChangeListener(ChangeListener)
- Add a listener to track when styles are added
or removed.
-
addStyle(String, Style)
- Add a new style into the style hierarchy.
-
copy(CharacterStyle, CharacterStyle)
-
-
getFont(String, int, int)
-
-
getFontMetrics(Font)
-
-
getStyle(String)
- Fetch a named style previously added to the document.
-
getStyleNames()
- Fetch the names of the styles defined.
-
isEqual(CharacterStyle, CharacterStyle)
- Compare the attributes of two character style definitions
to see if they are the same.
-
removeChangeListener(ChangeListener)
- Remove a listener that was tracking styles being
added or removed.
-
removeStyle(String)
- Remove a named style previously added to the document.
DEFAULT_STYLE
public static final String DEFAULT_STYLE
- The name given to the default logical style attached
to paragraphs.
ComponentElementName
public static final String ComponentElementName
- Name of elements used to represent components.
IconElementName
public static final String IconElementName
- Name of elements used to represent icons.
StyleContext
public StyleContext()
addStyle
public Style addStyle(String nm,
Style parent)
- Add a new style into the style hierarchy. Style attributes
resolve from bottom up so an attribute specified in a child
will override an attribute specified in the parent.
- Parameters:
- nm - The name of the style (must be unique within the
collection of named styles in the document). The name may
be null if the style is unnamed, but the caller is responsible
for managing the reference returned as an unnamed style can't
be fetched by name. An unnamed style may be useful for things
like character attribute overrides such as found in a style
run.
- parent - The parent style. This may be null if unspecified
attributes need not be resolved in some other style.
removeStyle
public void removeStyle(String nm)
- Remove a named style previously added to the document.
- Parameters:
- nm - The name of the style to remove
getStyle
public Style getStyle(String nm)
- Fetch a named style previously added to the document.
- Parameters:
- nm - The name of the style
getStyleNames
public String[] getStyleNames()
- Fetch the names of the styles defined.
addChangeListener
public void addChangeListener(ChangeListener l)
- Add a listener to track when styles are added
or removed.
removeChangeListener
public void removeChangeListener(ChangeListener l)
- Remove a listener that was tracking styles being
added or removed.
getFont
public Font getFont(String family,
int style,
int size)
getFontMetrics
public FontMetrics getFontMetrics(Font f)
isEqual
public static boolean isEqual(CharacterStyle s1,
CharacterStyle s2)
- Compare the attributes of two character style definitions
to see if they are the same.
copy
public static void copy(CharacterStyle from,
CharacterStyle to)
All Packages Class Hierarchy This Package Previous Next Index