On this page
Class StyleContext.NamedStyle
- All Implemented Interfaces:
Serializable,AttributeSet,MutableAttributeSet,Style
- Enclosing class:
-
StyleContext
public class StyleContext.NamedStyle extends Object implements Style, Serializable
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see XMLEncoder.
Nested Class Summary
Nested classes/interfaces declared in interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
Field Summary
| Modifier and Type | Field | Description |
|---|---|---|
protected ChangeEvent |
changeEvent |
Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property.
|
protected EventListenerList |
listenerList |
The change listeners for the model.
|
Fields declared in interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
Constructor Summary
| Constructor | Description |
|---|---|
NamedStyle() |
Creates a new named style, with a null name and parent.
|
NamedStyle |
Creates a new named style.
|
NamedStyle |
Creates a new named style.
|
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
void |
addAttribute |
Adds an attribute.
|
void |
addAttributes |
Adds a set of attributes to the element.
|
void |
addChangeListener |
Adds a change listener.
|
boolean |
containsAttribute |
Checks whether a given attribute name/value is defined.
|
boolean |
containsAttributes |
Checks whether the element contains all the attributes.
|
AttributeSet |
copyAttributes() |
Copies a set of attributes.
|
protected void |
fireStateChanged() |
Notifies all listeners that have registered interest for notification on this event type.
|
Object |
getAttribute |
Gets the value of an attribute.
|
int |
getAttributeCount() |
Gets the number of attributes that are defined.
|
Enumeration |
getAttributeNames() |
Gets the names of all attributes.
|
ChangeListener[] |
getChangeListeners() |
Returns an array of all the ChangeListeners added to this NamedStyle with addChangeListener().
|
<T extends EventListener> |
getListeners |
Return an array of all the listeners of the given type that were added to this model.
|
String |
getName() |
Fetches the name of the style.
|
AttributeSet |
getResolveParent() |
Gets attributes from the parent.
|
boolean |
isDefined |
Checks whether a given attribute is defined.
|
boolean |
isEqual |
Checks whether two attribute sets are equal.
|
void |
removeAttribute |
Removes an attribute from the set.
|
void |
removeAttributes |
Removes a set of attributes for the element.
|
void |
removeAttributes |
Removes a set of attributes for the element.
|
void |
removeChangeListener |
Removes a change listener.
|
void |
setName |
Changes the name of the style.
|
void |
setResolveParent |
Sets the resolving parent.
|
String |
toString() |
Converts the style to a string.
|
Field Details
listenerList
protected EventListenerList listenerList
changeEvent
protected transient ChangeEvent changeEvent
Constructor Details
NamedStyle
public NamedStyle(String name, Style parent)
- Parameters:
name- the style name, null for unnamedparent- the parent style, null if none- Since:
- 1.4
NamedStyle
public NamedStyle(Style parent)
- Parameters:
parent- the parent style, null if none- Since:
- 1.4
NamedStyle
public NamedStyle()
Method Details
toString
public String toString()
getName
public String getName()
setName
public void setName(String name)
- Parameters:
name- the new name
addChangeListener
public void addChangeListener(ChangeListener l)
- Specified by:
addChangeListenerin interfaceStyle- Parameters:
l- the change listener
removeChangeListener
public void removeChangeListener(ChangeListener l)
- Specified by:
removeChangeListenerin interfaceStyle- Parameters:
l- the change listener
getChangeListeners
public ChangeListener[] getChangeListeners()
ChangeListeners added to this NamedStyle with addChangeListener().
- Returns:
-
all of the
ChangeListeners added or an empty array if no listeners have been added - Since:
- 1.4
fireStateChanged
protected void fireStateChanged()
- See Also:
getListeners
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
- Type Parameters:
T- the listener type- Parameters:
listenerType- the type of listeners requested- Returns:
- all of the objects receiving listenerType notifications from this model
- Since:
- 1.3
getAttributeCount
public int getAttributeCount()
- Specified by:
getAttributeCountin interfaceAttributeSet- Returns:
- the number of attributes >= 0
- See Also:
isDefined
public boolean isDefined(Object attrName)
- Specified by:
isDefinedin interfaceAttributeSet- Parameters:
attrName- the non-null attribute name- Returns:
- true if the attribute is defined
- See Also:
isEqual
public boolean isEqual(AttributeSet attr)
- Specified by:
isEqualin interfaceAttributeSet- Parameters:
attr- the attribute set to check against- Returns:
- true if the same
- See Also:
copyAttributes
public AttributeSet copyAttributes()
- Specified by:
copyAttributesin interfaceAttributeSet- Returns:
- the copy
- See Also:
getAttribute
public Object getAttribute(Object attrName)
- Specified by:
getAttributein interfaceAttributeSet- Parameters:
attrName- the non-null attribute name- Returns:
- the attribute value
- See Also:
getAttributeNames
public Enumeration<?> getAttributeNames()
- Specified by:
getAttributeNamesin interfaceAttributeSet- Returns:
- the attribute names as an enumeration
- See Also:
containsAttribute
public boolean containsAttribute(Object name, Object value)
- Specified by:
containsAttributein interfaceAttributeSet- Parameters:
name- the non-null attribute namevalue- the attribute value- Returns:
- true if the name/value is defined
- See Also:
containsAttributes
public boolean containsAttributes(AttributeSet attrs)
- Specified by:
containsAttributesin interfaceAttributeSet- Parameters:
attrs- the attributes to check- Returns:
- true if the element contains all the attributes
- See Also:
getResolveParent
public AttributeSet getResolveParent()
- Specified by:
getResolveParentin interfaceAttributeSet- Returns:
- the attributes from the parent
- See Also:
addAttribute
public void addAttribute(Object name, Object value)
- Specified by:
addAttributein interfaceMutableAttributeSet- Parameters:
name- the non-null attribute namevalue- the attribute value- See Also:
addAttributes
public void addAttributes(AttributeSet attr)
- Specified by:
addAttributesin interfaceMutableAttributeSet- Parameters:
attr- the attributes to add- See Also:
removeAttribute
public void removeAttribute(Object name)
- Specified by:
removeAttributein interfaceMutableAttributeSet- Parameters:
name- the non-null attribute name- See Also:
removeAttributes
public void removeAttributes(Enumeration<?> names)
- Specified by:
removeAttributesin interfaceMutableAttributeSet- Parameters:
names- the attribute names- See Also:
removeAttributes
public void removeAttributes(AttributeSet attrs)
- Specified by:
removeAttributesin interfaceMutableAttributeSet- Parameters:
attrs- the attributes- See Also:
setResolveParent
public void setResolveParent(AttributeSet parent)
- Specified by:
setResolveParentin interfaceMutableAttributeSet- Parameters:
parent- the parent, null if none- See Also:
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/text/StyleContext.NamedStyle.html