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.


Variable Index

 o DEFAULT_STYLE
The name given to the default logical style attached to paragraphs.

Constructor Index

 o StyleContext()
Creates a new SytleContext object.

Method Index

 o addChangeListener(ChangeListener)
Adds a listener to track when styles are added or removed.
 o addStyle(String, Style)
Adds a new style into the style hierarchy.
 o getFont(String, int, int)
Gets a new font.
 o getFontMetrics(Font)
Returns font metrics for a font.
 o getStyle(String)
Fetches a named style previously added to the document
 o getStyleNames()
Fetches the names of the styles defined.
 o removeChangeListener(ChangeListener)
Removes a listener that was tracking styles being added or removed.
 o removeStyle(String)
Removes a named style previously added to the document.

Variables

 o DEFAULT_STYLE
 public static final String DEFAULT_STYLE
The name given to the default logical style attached to paragraphs.

Constructors

 o StyleContext
 public StyleContext()
Creates a new SytleContext object.

Methods

 o 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
 o removeStyle
 public void removeStyle(String nm)
Removes a named style previously added to the document.

Parameters:
nm - the name of the style to remove
 o 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
 o getStyleNames
 public Enumeration getStyleNames()
Fetches the names of the styles defined.

Returns:
the list of names
 o addChangeListener
 public void addChangeListener(ChangeListener l)
Adds a listener to track when styles are added or removed.

Parameters:
l - the change listener
 o removeChangeListener
 public void removeChangeListener(ChangeListener l)
Removes a listener that was tracking styles being added or removed.

Parameters:
l - the change listener
 o 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
 o 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