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 ComponentElementName
Name of elements used to represent components.
 o DEFAULT_STYLE
The name given to the default logical style attached to paragraphs.
 o IconElementName
Name of elements used to represent icons.

Constructor Index

 o StyleContext()

Method Index

 o addChangeListener(ChangeListener)
Add a listener to track when styles are added or removed.
 o addStyle(String, Style)
Add a new style into the style hierarchy.
 o copy(CharacterStyle, CharacterStyle)
 o getFont(String, int, int)
 o getFontMetrics(Font)
 o getStyle(String)
Fetch a named style previously added to the document.
 o getStyleNames()
Fetch the names of the styles defined.
 o isEqual(CharacterStyle, CharacterStyle)
Compare the attributes of two character style definitions to see if they are the same.
 o removeChangeListener(ChangeListener)
Remove a listener that was tracking styles being added or removed.
 o removeStyle(String)
Remove 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.

 o ComponentElementName
 public static final String ComponentElementName
Name of elements used to represent components.

 o IconElementName
 public static final String IconElementName
Name of elements used to represent icons.

Constructors

 o StyleContext
 public StyleContext()

Methods

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

Parameters:
nm - The name of the style to remove
 o getStyle
 public Style getStyle(String nm)
Fetch a named style previously added to the document.

Parameters:
nm - The name of the style
 o getStyleNames
 public String[] getStyleNames()
Fetch the names of the styles defined.

 o addChangeListener
 public void addChangeListener(ChangeListener l)
Add a listener to track when styles are added or removed.

 o removeChangeListener
 public void removeChangeListener(ChangeListener l)
Remove a listener that was tracking styles being added or removed.

 o getFont
 public Font getFont(String family,
                     int style,
                     int size)
 o getFontMetrics
 public FontMetrics getFontMetrics(Font f)
 o isEqual
 public static boolean isEqual(CharacterStyle s1,
                               CharacterStyle s2)
Compare the attributes of two character style definitions to see if they are the same.

 o copy
 public static void copy(CharacterStyle from,
                         CharacterStyle to)

All Packages  Class Hierarchy  This Package  Previous  Next  Index