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.
-
DEFAULT_STYLE
- The name given to the default logical style attached
to paragraphs.
-
StyleContext()
- Creates a new SytleContext object.
-
addChangeListener(ChangeListener)
- Adds a listener to track when styles are added
or removed.
-
addStyle(String, Style)
- Adds a new style into the style hierarchy.
-
getFont(String, int, int)
- Gets a new font.
-
getFontMetrics(Font)
- Returns font metrics for a font.
-
getStyle(String)
- Fetches a named style previously added to the document
-
getStyleNames()
- Fetches the names of the styles defined.
-
removeChangeListener(ChangeListener)
- Removes a listener that was tracking styles being
added or removed.
-
removeStyle(String)
- Removes 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.
StyleContext
public StyleContext()
- Creates a new SytleContext object.
addStyle
public Style addStyle(String nm,
Style parent)
- Adds 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.
- Returns:
- the created style
removeStyle
public void removeStyle(String nm)
- Removes a named style previously added to the document.
- Parameters:
- nm - the name of the style to remove
getStyle
public Style getStyle(String nm)
- Fetches a named style previously added to the document
- Parameters:
- nm - the name of the style
- Returns:
- the style
getStyleNames
public Enumeration getStyleNames()
- Fetches the names of the styles defined.
- Returns:
- the list of names
addChangeListener
public void addChangeListener(ChangeListener l)
- Adds a listener to track when styles are added
or removed.
- Parameters:
- l - the change listener
removeChangeListener
public void removeChangeListener(ChangeListener l)
- Removes a listener that was tracking styles being
added or removed.
- Parameters:
- l - the change listener
getFont
public Font getFont(String family,
int style,
int size)
- Gets a new font.
- Parameters:
- family - the font family
- style - the style of the font
- size - the point size
- Returns:
- the new font
getFontMetrics
public FontMetrics getFontMetrics(Font f)
- Returns font metrics for a font.
- Parameters:
- f - the font
- Returns:
- the metrics
All Packages Class Hierarchy This Package Previous Next Index