< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java

Print this page




  30 
  31 import javax.swing.*;
  32 import javax.swing.plaf.*;
  33 import javax.swing.plaf.basic.*;
  34 
  35 
  36 import java.awt.*;
  37 
  38 
  39 /**
  40  * A Windows L&amp;F implementation of LabelUI.  This implementation
  41  * is completely static, i.e. there's only one UIView implementation
  42  * that's shared by all JLabel objects.
  43  *
  44  * @author Hans Muller
  45  */
  46 
  47 public class MetalLabelUI extends BasicLabelUI
  48 {
  49    /**
  50     * The default <code>MetalLabelUI</code> instance. This field might
  51     * not be used. To change the default instance use a subclass which
  52     * overrides the <code>createUI</code> method, and place that class
  53     * name in defaults table under the key "LabelUI".
  54     */
  55     protected static MetalLabelUI metalLabelUI = new MetalLabelUI();
  56 
  57     private static final Object METAL_LABEL_UI_KEY = new Object();
  58 
  59     /**
  60      * Returns an instance of {@code MetalLabelUI}.
  61      *
  62      * @param c a component
  63      * @return an instance of {@code MetalLabelUI}
  64      */
  65     public static ComponentUI createUI(JComponent c) {
  66         if (System.getSecurityManager() != null) {
  67             AppContext appContext = AppContext.getAppContext();
  68             MetalLabelUI safeMetalLabelUI =
  69                     (MetalLabelUI) appContext.get(METAL_LABEL_UI_KEY);
  70             if (safeMetalLabelUI == null) {
  71                 safeMetalLabelUI = new MetalLabelUI();
  72                 appContext.put(METAL_LABEL_UI_KEY, safeMetalLabelUI);




  30 
  31 import javax.swing.*;
  32 import javax.swing.plaf.*;
  33 import javax.swing.plaf.basic.*;
  34 
  35 
  36 import java.awt.*;
  37 
  38 
  39 /**
  40  * A Windows L&amp;F implementation of LabelUI.  This implementation
  41  * is completely static, i.e. there's only one UIView implementation
  42  * that's shared by all JLabel objects.
  43  *
  44  * @author Hans Muller
  45  */
  46 
  47 public class MetalLabelUI extends BasicLabelUI
  48 {
  49    /**
  50     * The default {@code MetalLabelUI} instance. This field might
  51     * not be used. To change the default instance use a subclass which
  52     * overrides the {@code createUI} method, and place that class
  53     * name in defaults table under the key "LabelUI".
  54     */
  55     protected static MetalLabelUI metalLabelUI = new MetalLabelUI();
  56 
  57     private static final Object METAL_LABEL_UI_KEY = new Object();
  58 
  59     /**
  60      * Returns an instance of {@code MetalLabelUI}.
  61      *
  62      * @param c a component
  63      * @return an instance of {@code MetalLabelUI}
  64      */
  65     public static ComponentUI createUI(JComponent c) {
  66         if (System.getSecurityManager() != null) {
  67             AppContext appContext = AppContext.getAppContext();
  68             MetalLabelUI safeMetalLabelUI =
  69                     (MetalLabelUI) appContext.get(METAL_LABEL_UI_KEY);
  70             if (safeMetalLabelUI == null) {
  71                 safeMetalLabelUI = new MetalLabelUI();
  72                 appContext.put(METAL_LABEL_UI_KEY, safeMetalLabelUI);


< prev index next >