JavaTM Platform
Standard Ed. 6

javax.swing.plaf.basic
�� BasicLabelUI

java.lang.Object
  �̳��� javax.swing.plaf.ComponentUI
      �̳��� javax.swing.plaf.LabelUI
          �̳��� javax.swing.plaf.basic.BasicLabelUI
������ʵ�ֵĽӿڣ�
PropertyChangeListener, EventListener
ֱ����֪���ࣺ
MetalLabelUI

public class BasicLabelUI
extends LabelUI
implements PropertyChangeListener

LabelUI �� Windows L&F ʵ�֡���ʵ����ȫ�Ǿ�̬�ģ������� JLabel ���������һ�� UIView ʵ�֡�


�ֶ�ժҪ
protected static BasicLabelUI labelUI
          Ĭ�� BasicLabelUI ʵ����
 
���췽��ժҪ
BasicLabelUI()
           
 
����ժҪ
static ComponentUI createUI(JComponent c)
           
 int getBaseline(JComponent c, int width, int height)
          ���ػ��ߡ�
 Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
          ����һ��ö�٣���ָʾ����Ļ���������С�ĸı���������ġ�
 Dimension getMaximumSize(JComponent c)
          ����ָ��������ʺ���۵�����С��
 Dimension getMinimumSize(JComponent c)
          ����ָ��������ʺ���۵���С��С��
 Dimension getPreferredSize(JComponent c)
          ����ָ��������ʺ���۵���ѡ��С��
protected  void installComponents(JLabel c)
           
protected  void installDefaults(JLabel c)
           
protected  void installKeyboardActions(JLabel l)
           
protected  void installListeners(JLabel c)
           
 void installUI(JComponent c)
          ����ָ�������ʹ���ʺ���ۡ�
protected  String layoutCL(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR)
          ������ת���� SwingUtilities.layoutCompoundLabel()��
 void paint(Graphics g, JComponent c)
          ʹ��ǰ��ɫ���Ʊ�ǩ�ı��������ǩ��͸���������ñ���ɫ��������������
protected  void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY)
          ���� background.lighter() �� clippedText ������ textX��textY ����Ȼ������ background.darker() �������ƶ�һ�����ء�
protected  void paintEnabledText(JLabel l, Graphics g, String s, int textX, int textY)
          ���ñ�ǩ��ǰ��ɫ�� clippedText ������ textX��textY ����
 void propertyChange(PropertyChangeEvent e)
          �ڰ����Է�������ʱ���ô˷�����
protected  void uninstallComponents(JLabel c)
           
protected  void uninstallDefaults(JLabel c)
           
protected  void uninstallKeyboardActions(JLabel c)
           
protected  void uninstallListeners(JLabel c)
           
 void uninstallUI(JComponent c)
          �� installUI �ڼ䣬��ָ������Ϸ���ִ�е����ò�����
 
���� javax.swing.plaf.ComponentUI �̳еķ���
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
���� java.lang.Object �̳еķ���
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

�ֶ���ϸ��Ϣ

labelUI

protected static BasicLabelUI labelUI
Ĭ�� BasicLabelUI ʵ�������Բ�ʹ�ô��ֶΡ�Ҫ����Ĭ��ʵ������ʹ����д createUI ���������࣬����������������Ĭ�ϱ��� "LabelUI" ��֮�¡�

���췽����ϸ��Ϣ

BasicLabelUI

public BasicLabelUI()
������ϸ��Ϣ

layoutCL

protected String layoutCL(JLabel label,
                          FontMetrics fontMetrics,
                          String text,
                          Icon icon,
                          Rectangle viewR,
                          Rectangle iconR,
                          Rectangle textR)
������ת���� SwingUtilities.layoutCompoundLabel()���˷���λ�ڴ˴��Ա������ִ���ض��� Label �IJ��֣�������ʹ��������һ�㡣

������
SwingUtilities.layoutCompoundLabel(javax.swing.JComponent, java.awt.FontMetrics, java.lang.String, javax.swing.Icon, int, int, int, int, java.awt.Rectangle, java.awt.Rectangle, java.awt.Rectangle, int)

paintEnabledText

protected void paintEnabledText(JLabel l,
                                Graphics g,
                                String s,
                                int textX,
                                int textY)
���ñ�ǩ��ǰ��ɫ�� clippedText ������ textX��textY ����

������
paint(java.awt.Graphics, javax.swing.JComponent), paintDisabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int)

paintDisabledText

protected void paintDisabledText(JLabel l,
                                 Graphics g,
                                 String s,
                                 int textX,
                                 int textY)
���� background.lighter() �� clippedText ������ textX��textY ����Ȼ������ background.darker() �������ƶ�һ�����ء�

������
paint(java.awt.Graphics, javax.swing.JComponent), paintEnabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int)

paint

public void paint(Graphics g,
                  JComponent c)
ʹ��ǰ��ɫ���Ʊ�ǩ�ı��������ǩ��͸���������ñ���ɫ��������������Label �ı����� paintEnabledText() �� paintDisabledText() ���Ƶġ���ǩ���ֵ�λ���� layoutCL ���㡣

���ǣ�
�� ComponentUI �е� paint
������
g - �������н��л��Ƶ� Graphics ������
c - �����Ƶ�������˲����������ԣ������ UI ��������״̬�IJ��ɶ����������������ʹ�øò���
������
paintEnabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int), paintDisabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int), layoutCL(javax.swing.JLabel, java.awt.FontMetrics, java.lang.String, javax.swing.Icon, java.awt.Rectangle, java.awt.Rectangle, java.awt.Rectangle)

getPreferredSize

public Dimension getPreferredSize(JComponent c)
���� ComponentUI ���Ƶ�����
����ָ��������ʺ���۵���ѡ��С��������� null������ѡ��С��������IJ��ֹ��������㣨���ڰ�װ���ض����ֹ�������������ԣ�������ѡ���������˷�����Ĭ��ʵ�ַ��� null��

���ǣ�
�� ComponentUI �е� getPreferredSize
������
c - ����ѯ����ѡ��С��������˲����������ԣ������ UI ��������״̬�IJ��ɶ����������������ʹ�øò���
������
JComponent.getPreferredSize(), LayoutManager.preferredLayoutSize(java.awt.Container)

getMinimumSize

public Dimension getMinimumSize(JComponent c)
���� ComponentUI ���Ƶ�����
����ָ��������ʺ���۵���С��С��������� null������С��С��������IJ��ֹ��������㣨���ڰ�װ���ض����ֹ�������������ԣ�������ѡ���������˷�����Ĭ��ʵ�ֵ��� getPreferredSize �����ظ�ֵ��

���ǣ�
�� ComponentUI �е� getMinimumSize
������
c - ����ѯ����С��С��������˲����������ԣ������ UI ��������״̬�IJ��ɶ����������������ʹ�øò���
���أ�
getPreferredSize(c)
������
JComponent.getMinimumSize(), LayoutManager.minimumLayoutSize(java.awt.Container), ComponentUI.getPreferredSize(javax.swing.JComponent)

getMaximumSize

public Dimension getMaximumSize(JComponent c)
���� ComponentUI ���Ƶ�����
����ָ��������ʺ���۵�����С��������� null��������С��������IJ��ֹ��������㣨���ڰ�װ���ض����ֹ�������������ԣ�������ѡ���������˷�����Ĭ��ʵ�ֵ��� getPreferredSize �����ظ�ֵ��

���ǣ�
�� ComponentUI �е� getMaximumSize
������
c - ����ѯ������С��������˲����������ԣ������ UI ��������״̬�IJ��ɶ����������������ʹ�øò���
���أ�
getPreferredSize(c)
������
JComponent.getMaximumSize(), LayoutManager2.maximumLayoutSize(java.awt.Container)

getBaseline

public int getBaseline(JComponent c,
                       int width,
                       int height)
���ػ��ߡ�

���ǣ�
�� ComponentUI �е� getBaseline
������
c - Ϊ��������ߵ� JComponent
width - Ϊ���ȡ���ߵĿ���
height - Ϊ���ȡ���ߵĸ߶�
���أ�
���ߣ����û�к����Ļ��ߣ��򷵻� < 0 ��ֵ
�׳���
NullPointerException - ��� c Ϊ null
IllegalArgumentException - ������Ȼ�߶� < 0
�����°汾��ʼ��
1.6
������
JComponent.getBaseline(int, int)

getBaselineResizeBehavior

public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
����һ��ö�٣���ָʾ����Ļ���������С�ĸı���������ġ�

���ǣ�
�� ComponentUI �е� getBaselineResizeBehavior
������
c - Ϊ�䷵�ص�����С��Ϊ�� JComponent
���أ�
һ��ö�٣�ָʾ��������������С�ĸı����������
�׳���
NullPointerException - ��� c Ϊ null
�����°汾��ʼ��
1.6
������
JComponent.getBaseline(int, int)

installUI

public void installUI(JComponent c)
���� ComponentUI ���Ƶ�����
����ָ�������ʹ���ʺ���ۡ��� ComponentUI ʵ������Ϊ UI ί�а�װ��ָ�������ʱ���ɵ��ô˷������˷���Ӧ��Ϊ�������������������������·��棺
  1. ������ϰ�װ������ɫ�����塢�߿�ͼ�ꡢ��͸���Եȷ��������Ĭ������ֵ��ֻҪ�п��ܣ����� Ӧ����д�ɿͻ��˳����ʼ��������ֵ��
  2. ���б�Ҫ����������ϰ�װһ�� LayoutManager��
  3. ��������������������/���ӵ�����С�
  4. ������ϴ���/��װ�¼���������
  5. Ϊ�˼����ʵ���Ӧ������Ը��ģ���������ϴ���/��װһ�� PropertyChangeListener��
  6. ������ϰ�װ���� UI�����Ƿ��������ȵȣ���
  7. ��ʼ���κ��ʵ���ʵ�����ݡ�

���ǣ�
�� ComponentUI �е� installUI
������
c - ����װ�� UI ί�е����
������
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

uninstallUI

public void uninstallUI(JComponent c)
���� ComponentUI ���Ƶ�����
�� installUI �ڼ䣬��ָ������Ϸ���ִ�е����ò��������� UIComponent ʵ������Ϊ UI ί�д�ָ��������Ƴ�ʱ���ɵ��ô˷������˷���Ӧ��ȡ���� installUI ��ִ�е����ò������dz�С�ĵ�ʹ JComponent ʵ������ij�ֽྻ״̬��û�ж������������û���ض�����۵����Զ���ȵ�)����������Ӧ�ð������·��棺
  1. ��������Ƴ����� UI ���õı߿�
  2. ��������Ƴ����� UI ���õIJ��ֹ�������
  3. ��������Ƴ����� UI ���ӵ��������
  4. ��������Ƴ����� UI ���ӵ��¼�/������������
  5. ��������Ƴ����� UI ��װ�ļ��� UI��
  6. ʹ�����ѷ����ʵ�����ݶ�����Ч���Ӷ��������� GC ������

���ǣ�
�� ComponentUI �е� uninstallUI
������
c - �����Ƴ��� UI ί�е�������˲����������ԣ������ UI ��������״̬�IJ��ɶ����������������ʹ�øò���
������
ComponentUI.installUI(javax.swing.JComponent), JComponent.updateUI()

installDefaults

protected void installDefaults(JLabel c)

installListeners

protected void installListeners(JLabel c)

installComponents

protected void installComponents(JLabel c)

installKeyboardActions

protected void installKeyboardActions(JLabel l)

uninstallDefaults

protected void uninstallDefaults(JLabel c)

uninstallListeners

protected void uninstallListeners(JLabel c)

uninstallComponents

protected void uninstallComponents(JLabel c)

uninstallKeyboardActions

protected void uninstallKeyboardActions(JLabel c)

createUI

public static ComponentUI createUI(JComponent c)

propertyChange

public void propertyChange(PropertyChangeEvent e)
�ӽӿ� PropertyChangeListener ���Ƶ�����
�ڰ����Է�������ʱ���ô˷�����

ָ���ߣ�
�ӿ� PropertyChangeListener �е� propertyChange
������
e - �����¼�Դ���Ѹ������Ե� PropertyChangeEvent ����

JavaTM Platform
Standard Ed. 6

�ύ��������
�йظ���� API �ο����ϺͿ�����Ա�ĵ�������� Java SE ������Ա�ĵ������ĵ���������ϸ�ġ����򿪷���Ա���������Լ�������������ﶨ�塢ʹ�ü��ɺ͹�������ʾ����

��Ȩ���� 2007 Sun Microsystems, Inc. ��������Ȩ���� ����������֤��������������ĵ����·ַ�������