public class StyleContext.NamedStyle extends Object implements Serializable, Style
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute| Modifier and Type | Field and Description |
|---|---|
protected ChangeEvent |
changeEvent |
protected EventListenerList |
listenerList |
NameAttribute, ResolveAttribute| Constructor and Description |
|---|
StyleContext.NamedStyle() |
StyleContext.NamedStyle(String name,
Style parent) |
StyleContext.NamedStyle(Style parent) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttribute(Object name,
Object value)
Adds an attribute with the given
name and value
to the set. |
void |
addAttributes(AttributeSet attr)
Adds all the attributes from
attributes to this set. |
void |
addChangeListener(ChangeListener l)
Adds a
ChangeListener object to the style. |
boolean |
containsAttribute(Object name,
Object value)
Returns
true if this AttributeSet contains
an attribute with the specified name and value,
false otherwise. |
boolean |
containsAttributes(AttributeSet attrs)
Returns
true of this AttributeSet contains all
of the specified attributes. |
AttributeSet |
copyAttributes()
Creates and returns a copy of this
AttributeSet. |
protected void |
fireStateChanged() |
Object |
getAttribute(Object attrName)
Returns the attribute with the specified
key or
null if no such attribute is defined in this
AttributeSet and its resolving parents. |
int |
getAttributeCount()
Returns the number of attributes that are stored locally in this
AttributeSet. |
Enumeration<?> |
getAttributeNames()
Returns the names of the attributes that are stored in this
AttributeSet. |
ChangeListener[] |
getChangeListeners() |
<T extends EventListener> |
getListeners(Class<T> listenerType) |
String |
getName()
Returns the name of the style.
|
AttributeSet |
getResolveParent()
Returns the resolving parent of this
AttributeSet. |
boolean |
isDefined(Object attrName)
Returns
true if an attribute with the specified name is
defined locally in this AttributeSet, without resolving
through the resolving parents. |
boolean |
isEqual(AttributeSet attr)
Returns
true if all of the attributes in attr
are equal to the attributes in this AttributeSet,
false otherwise. |
void |
removeAttribute(Object name)
Removes the attribute with the specified
name, if this
attribute is defined. |
void |
removeAttributes(AttributeSet attrs)
Removes attributes from this set if they are found in the
given set.
|
void |
removeAttributes(Enumeration<?> names)
Removes the attributes listed in
names. |
void |
removeChangeListener(ChangeListener l)
Removes a
ChangeListener from to the style. |
void |
setName(String n) |
void |
setResolveParent(AttributeSet parent)
Sets the reolving parent for this set.
|
String |
toString()
Convert this Object to a human-readable String.
|
protected transient ChangeEvent changeEvent
protected EventListenerList listenerList
public StyleContext.NamedStyle()
public StyleContext.NamedStyle(Style parent)
public StyleContext.NamedStyle(String name, Style parent)
public String getName()
Stylepublic void addChangeListener(ChangeListener l)
StyleChangeListener object to the style.addChangeListener in interface Stylel - the listener object to addpublic void removeChangeListener(ChangeListener l)
StyleChangeListener from to the style.removeChangeListener in interface Stylel - the listener object to remove,public <T extends EventListener> T[] getListeners(Class<T> listenerType)
public ChangeListener[] getChangeListeners()
protected void fireStateChanged()
public void addAttribute(Object name, Object value)
MutableAttributeSetname and value
to the set. If the set already contains an attribute with the given
name, the attribute value is updated.addAttribute in interface MutableAttributeSetname - the attribute name (null not permitted).value - the value (null not permitted).public void addAttributes(AttributeSet attr)
MutableAttributeSetattributes to this set.addAttributes in interface MutableAttributeSetattr - the set of attributes to add (null not
permitted).public boolean containsAttribute(Object name, Object value)
AttributeSettrue if this AttributeSet contains
an attribute with the specified name and value,
false otherwise.containsAttribute in interface AttributeSetname - the name of the requested attributevalue - the value of the requested attributetrue if this AttributeSet contains
an attribute with the specified name and
value, false otherwisepublic boolean containsAttributes(AttributeSet attrs)
AttributeSettrue of this AttributeSet contains all
of the specified attributes.containsAttributes in interface AttributeSetattrs - the requested attributestrue of this AttributeSet contains all
of the specified attributespublic AttributeSet copyAttributes()
AttributeSetAttributeSet.copyAttributes in interface AttributeSetAttributeSetpublic Object getAttribute(Object attrName)
AttributeSetkey or
null if no such attribute is defined in this
AttributeSet and its resolving parents.getAttribute in interface AttributeSetattrName - the key of the attribute that is looked upkey or
null if no such attribute is defined in this
AttributeSet and its resolving parentspublic int getAttributeCount()
AttributeSetAttributeSet.getAttributeCount in interface AttributeSetAttributeSetpublic Enumeration<?> getAttributeNames()
AttributeSetAttributeSet.getAttributeNames in interface AttributeSetAttributeSetpublic boolean isDefined(Object attrName)
AttributeSettrue if an attribute with the specified name is
defined locally in this AttributeSet, without resolving
through the resolving parents.isDefined in interface AttributeSettrue if an attribute with the specified name is
defined locally in this AttributeSetpublic boolean isEqual(AttributeSet attr)
AttributeSettrue if all of the attributes in attr
are equal to the attributes in this AttributeSet,
false otherwise.isEqual in interface AttributeSetattr - the attributes to be compared to thistrue if all of the attributes in attr
are equal to the attributes in this AttributeSet,
false otherwisepublic void removeAttribute(Object name)
MutableAttributeSetname, if this
attribute is defined. This method will only remove an attribute from
this set, not from the resolving parent.removeAttribute in interface MutableAttributeSetname - the attribute name (null not permitted).public void removeAttributes(AttributeSet attrs)
MutableAttributeSetattributes has the same resolving parent as this set, the
parent will be removed from this set.removeAttributes in interface MutableAttributeSetattrs - the attributes (null not permitted).public void removeAttributes(Enumeration<?> names)
MutableAttributeSetnames.removeAttributes in interface MutableAttributeSetnames - the attribute names (null not permitted).public AttributeSet getResolveParent()
AttributeSetAttributeSet.
If a key is not stored locally, then a AttributeSet.getAttribute(Object)
request is resolved up in the resolving parent of this
AttributeSet.getResolveParent in interface AttributeSetAttributeSetpublic void setResolveParent(AttributeSet parent)
MutableAttributeSetsetResolveParent in interface MutableAttributeSetparent - the parent attribute set (null not permitted).public String toString()
ObjectSystem.out.println()
and such.
It is typical, but not required, to ensure that this method
never completes abruptly with a RuntimeException.
This method will be called when performing string
concatenation with this object. If the result is
null, string concatenation will instead
use "null".
The default implementation returns
getClass().getName() + "@" +
Integer.toHexString(hashCode()).
toString in class ObjectObject.getClass(),
Object.hashCode(),
Class.getName(),
Integer.toHexString(int)