KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > metal > MetalLabelUI


1 /*
2  * @(#)MetalLabelUI.java 1.14 05/10/31
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.plaf.metal;
9
10 import com.sun.java.swing.SwingUtilities2;
11 import javax.swing.*;
12 import javax.swing.plaf.*;
13 import javax.swing.plaf.basic.*;
14
15
16 import java.awt.*;
17
18
19 /**
20  * A Windows L&F implementation of LabelUI. This implementation
21  * is completely static, i.e. there's only one UIView implementation
22  * that's shared by all JLabel objects.
23  *
24  * @version 1.14 10/31/05
25  * @author Hans Muller
26  */

27
28 public class MetalLabelUI extends BasicLabelUI
29 {
30     protected static MetalLabelUI JavaDoc metalLabelUI = new MetalLabelUI JavaDoc();
31     private final static MetalLabelUI JavaDoc SAFE_METAL_LABEL_UI = new MetalLabelUI JavaDoc();
32
33
34     public static ComponentUI createUI(JComponent c) {
35         if (System.getSecurityManager() != null) {
36             return SAFE_METAL_LABEL_UI;
37         } else {
38             return metalLabelUI;
39         }
40     }
41
42     /**
43      * Just paint the text gray (Label.disabledForeground) rather than
44      * in the labels foreground color.
45      *
46      * @see #paint
47      * @see #paintEnabledText
48      */

49     protected void paintDisabledText(JLabel l, Graphics g, String JavaDoc s, int textX, int textY)
50     {
51     int mnemIndex = l.getDisplayedMnemonicIndex();
52     g.setColor(UIManager.getColor("Label.disabledForeground"));
53     SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex,
54                                                    textX, textY);
55     }
56 }
57
58
Popular Tags