|
JavaTM Platform Standard Ed. 6 |
|||||||||
��һ���� ��һ���� | ��� ��� ������ | |||||||||
ժҪ�� Ƕ�� | �ֶ� | ���췽�� | ���� | ��ϸ��Ϣ�� �ֶ� | ���췽�� | ���� |
java.lang.Objectjavax.swing.text.StyleContext
public class StyleContext
��ʽ�ؼ����������Դ����������ȷ����Դ��������ڣ��ٶ�����Դ����һ�������������ָ�����Դ�Ļ��棬��Щ��Դ�����������ɫ�ȣ�ͨ��������ʽ����������á������Ҫ��������Դ�Ĺ���������ɶ���ĵ����������ࡣ
�����С���Լ��ṩ��Ч֧�֣���ͨ�������������䲻���������ѹ����ЩС���Լ�����Ϊ������ʽ�����ظ��ģ����Թ�����DZ�ܷdz����Ҹ��Ƴɱ�Ҳ�൱�������ϴ�ļ��Ͻ����˹����Ŀ����ԣ�������Զ�ת����һ�ֿռ������ʵ͵�ʵ�֡�
���棺����������л��������Ժ�� Swing �汾�����ݡ���ǰ���л�֧�������ڶ��ڴ洢��������ͬ Swing �汾��Ӧ�ó���֮��� RMI���� 1.4 �汾��ʼ������ java.beans
����������֧������ JavaBeansTM ���ڴ洢�Ĺ��ܡ���μ� XMLEncoder
��
Ƕ����ժҪ | |
---|---|
class |
StyleContext.NamedStyle
ͨ�����ڱ�ʾ�ַ��Ͷ�����ʽ�����Լ��ϡ� |
class |
StyleContext.SmallAttributeSet
������������д洢���������ԡ� |
�ֶ�ժҪ | |
---|---|
static String |
DEFAULT_STYLE
�����������ص�Ĭ������ʽ�����ơ� |
���췽��ժҪ | |
---|---|
StyleContext()
�����µ� StyleContext ���� |
����ժҪ | |
---|---|
AttributeSet |
addAttribute(AttributeSet old,
Object name,
Object value)
������ļ������������ԣ��������µ��д����Եļ��ϡ� |
AttributeSet |
addAttributes(AttributeSet old,
AttributeSet attr)
��Ԫ���������Լ��� |
void |
addChangeListener(ChangeListener l)
����һ�����������Ը��ٺ�ʱ���ӻ�ɾ����ʽ�� |
Style |
addStyle(String nm,
Style parent)
���µ���ʽ���ӵ���ʽ����С� |
protected MutableAttributeSet |
createLargeAttributeSet(AttributeSet a)
����һ���Կռ�����ȡʱ��Ĵ����Լ��ϡ� |
protected StyleContext.SmallAttributeSet |
createSmallAttributeSet(AttributeSet a)
����һ���������ڹ�����ѹ�����Լ��� |
Color |
getBackground(AttributeSet attr)
ʹ��һ�����Լ�������ת����Ϊһ������ɫ�淶�� |
ChangeListener[] |
getChangeListeners()
����ʹ�� addChangeListener() ���ӵ��� StyleContext �е����� ChangeListener ��ɵ����顣 |
protected int |
getCompressionThreshold()
���ؼ�/ֵ�Ե������Ŀ�����Խ���ѹ����һ��Ωһ/���ɱ�ļ����С� |
static StyleContext |
getDefaultStyleContext()
�����������ĵ�������Ĭ�� AttributeContext����Щ�ĵ���Ӱ�춨��/�ṩ���Լ��������ġ� |
AttributeSet |
getEmptySet()
��ȡ�� AttributeSet�� |
Font |
getFont(AttributeSet attr)
�����Լ��л�ȡ���塣 |
Font |
getFont(String family,
int style,
int size)
��ȡ�����塣 |
FontMetrics |
getFontMetrics(Font f)
��ȡij������������� |
Color |
getForeground(AttributeSet attr)
ʹ��һ�����Լ�������ת����Ϊһ��ǰ��ɫ�淶�� |
static Object |
getStaticAttribute(Object key)
������ǰ�� registerStaticAttributeKey ע��Ķ��� |
static Object |
getStaticAttributeKey(Object key)
������ key ��Ҫע��� String |
Style |
getStyle(String nm)
��ȡ��ǰ���ӵ��ĵ��е���������ʽ |
Enumeration<?> |
getStyleNames()
��ȡ�������ʽ���ơ� |
void |
readAttributes(ObjectInputStream in,
MutableAttributeSet a)
�������Ե��ض��������ĵĴ����� |
static void |
readAttributeSet(ObjectInputStream in,
MutableAttributeSet a)
����ǰͨ�� writeAttributeSet д���ĸ��������������ж�ȡһ�����Լ��� |
void |
reclaim(AttributeSet a)
���� MutableAttributeSet ʵ�ֲ�����Ҫ�ļ��ϡ� |
static void |
registerStaticAttributeKey(Object key)
��һ������ע��Ϊ�������Լ��е�һ�����ľ�̬���� |
AttributeSet |
removeAttribute(AttributeSet old,
Object name)
�Ӽ������Ƴ�һ�����ԡ� |
AttributeSet |
removeAttributes(AttributeSet old,
AttributeSet attrs)
�Ƴ�Ԫ�ص����Լ��� |
AttributeSet |
removeAttributes(AttributeSet old,
Enumeration<?> names)
�Ƴ�Ԫ�ص�һ�����Լ��� |
void |
removeChangeListener(ChangeListener l)
�Ƴ�һ�������������ӻ��Ƴ���ʽ���������� |
void |
removeStyle(String nm)
�Ƴ���ǰ���ӵ��ĵ��е���������ʽ�� |
String |
toString()
�� StyleContext ת����Ϊ String�� |
void |
writeAttributes(ObjectOutputStream out,
AttributeSet a)
д�����Ե��ض��������ĵĴ����� |
static void |
writeAttributeSet(ObjectOutputStream out,
AttributeSet a)
�����Լ�д�뵽�����Ķ������Ա����л��� |
���� java.lang.Object �̳еķ��� |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
�ֶ���ϸ��Ϣ |
---|
public static final String DEFAULT_STYLE
���췽����ϸ��Ϣ |
---|
public StyleContext()
������ϸ��Ϣ |
---|
public static final StyleContext getDefaultStyleContext()
public Style addStyle(String nm, Style parent)
nm
- ��ʽ�����ƣ������ĵ���������ʽ�ļ����ڱ�����Ωһ�ģ��������ʽδ������������ƿ���Ϊ null�����ǵ�����Ҫ����������ص����ã���Ϊδ��������ʽ����ͨ�������ƻ�ȡ��δ��������ʽ�������������ַ�������д�������������������ʽ�����У���parent
- ����ʽ�����δָ�������Բ���Ҫ��������ʽ���������ֵ����Ϊ null��
public void removeStyle(String nm)
nm
- Ҫ�Ƴ�����ʽ����public Style getStyle(String nm)
nm
- ��ʽ����
public Enumeration<?> getStyleNames()
public void addChangeListener(ChangeListener l)
l
- ����������public void removeChangeListener(ChangeListener l)
l
- ����������public ChangeListener[] getChangeListeners()
ChangeListener
��ɵ����顣
ChangeListener
��������û������������ʱ����һ��������public Font getFont(AttributeSet attr)
attr
- ���Լ�
public Color getForeground(AttributeSet attr)
attr
- ���Լ�
public Color getBackground(AttributeSet attr)
attr
- ���Լ�
public Font getFont(String family, int style, int size)
family
- ����ϵ�У��� "Monospaced"��style
- �������ʽ������ Font.PLAIN��size
- ���С����ֵ >= 1
public FontMetrics getFontMetrics(Font f)
f
- ����
public AttributeSet addAttribute(AttributeSet old, Object name, Object value)
��Ȼ����� Swing ���������̰߳�ȫ�ģ����˷������̰߳�ȫ�ġ��йظ�����Ϣ������� How to Use Threads��
AbstractDocument.AttributeContext
�е� addAttribute
old
- ԭ�����Լ�name
- �� null ��������value
- ����ֵ
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
public AttributeSet addAttributes(AttributeSet old, AttributeSet attr)
��Ȼ����� Swing ���������̰߳�ȫ�ģ����˷������̰߳�ȫ�ġ��йظ�����Ϣ������� How to Use Threads��
AbstractDocument.AttributeContext
�е� addAttributes
old
- ԭ�����Լ�attr
- Ҫ���ӵ�����
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
public AttributeSet removeAttribute(AttributeSet old, Object name)
��Ȼ����� Swing ���������̰߳�ȫ�ģ����˷������̰߳�ȫ�ġ��йظ�����Ϣ������� How to Use Threads��
AbstractDocument.AttributeContext
�е� removeAttribute
old
- ԭ�е����Լ�name
- �� null ��������
MutableAttributeSet.removeAttribute(java.lang.Object)
public AttributeSet removeAttributes(AttributeSet old, Enumeration<?> names)
��Ȼ����� Swing ���������̰߳�ȫ�ģ����˷������̰߳�ȫ�ġ��йظ�����Ϣ������� How to Use Threads��
AbstractDocument.AttributeContext
�е� removeAttributes
old
- ԭ�����Լ�names
- ������
MutableAttributeSet.removeAttributes(java.util.Enumeration)
public AttributeSet removeAttributes(AttributeSet old, AttributeSet attrs)
��Ȼ����� Swing ���������̰߳�ȫ�ģ����˷������̰߳�ȫ�ġ��йظ�����Ϣ������� How to Use Threads��
AbstractDocument.AttributeContext
�е� removeAttributes
old
- ԭ�����Լ�attrs
- ����
MutableAttributeSet.removeAttributes(java.util.Enumeration)
public AttributeSet getEmptySet()
AbstractDocument.AttributeContext
�е� getEmptySet
public void reclaim(AttributeSet a)
��Ȼ����� Swing ���������̰߳�ȫ�ģ����˷������̰߳�ȫ�ġ��йظ�����Ϣ������� How to Use Threads��
AbstractDocument.AttributeContext
�е� reclaim
a
- Ҫ���յļ���protected int getCompressionThreshold()
protected StyleContext.SmallAttributeSet createSmallAttributeSet(AttributeSet a)
a
- ��ѹ����ʽ��ʾ�����Լ���protected MutableAttributeSet createLargeAttributeSet(AttributeSet a)
a
- �Ը�����ʽ��ʾ�����Լ���public String toString()
Object
�е� toString
public void writeAttributes(ObjectOutputStream out, AttributeSet a) throws IOException
IOException
public void readAttributes(ObjectInputStream in, MutableAttributeSet a) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
public static void writeAttributeSet(ObjectOutputStream out, AttributeSet a) throws IOException
registerStaticAttributeKey
����ע��ľ�̬���Լ����κ�û��ע��Ϊ��̬�������Լ�������ֱ�����л������������е�ֵ�����л���
out
- �����a
- ���Լ�
IOException
- ��������κ� I/O ����public static void readAttributeSet(ObjectInputStream in, MutableAttributeSet a) throws ClassNotFoundException, IOException
writeAttributeSet
д���ĸ��������������ж�ȡһ�����Լ����⽫��ͼ����ȥ�ľ�̬������ָ�Ϊ��ǰ������еľ�̬��������ٶ�ʹ�� registerStaticAttributeKey
����ֻע������Щ�������������������Խ������õ������Ŀɱ伯���С�
in
- ������ȡ�������ݵĶ�������a
- �������Զ�������Լ�
ClassNotFoundException
- ����ڶ�ȡ������ʱ�������ϴ��ݡ�
IOException
- ����ڶ�ȡ������ʱ�������ϴ��ݡ�public static void registerStaticAttributeKey(Object key)
���� 1.1 �汾���µ�������ϵIJ������⽫ʹ���� toString
���ӵ����������ص�ֵ��Ϊ�����Ժ����¼���ʱ����һ�£��� toString �����ص�ֵ��Ӧ�ð���������ã���Ӧ���� Object �еĶ�������ʵ�֣���
key
- �� null �����public static Object getStaticAttribute(Object key)
registerStaticAttributeKey
ע��Ķ���
public static Object getStaticAttributeKey(Object key)
key
��Ҫע��� String
getStaticAttribute(java.lang.Object)
,
registerStaticAttributeKey(java.lang.Object)
|
JavaTM Platform Standard Ed. 6 |
|||||||||
��һ���� ��һ���� | ��� ��� ������ | |||||||||
ժҪ�� Ƕ�� | �ֶ� | ���췽�� | ���� | ��ϸ��Ϣ�� �ֶ� | ���췽�� | ���� |
��Ȩ���� 2007 Sun Microsystems, Inc. ��������Ȩ���� ����������֤��������������ĵ����·ַ�������