author | yan |
Mon, 30 Jun 2014 16:32:36 +0400 | |
changeset 25178 | dbab904451e9 |
parent 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
20169
diff
changeset
|
2 |
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.swing.plaf.metal; |
|
27 |
||
28 |
import sun.swing.SwingUtilities2; |
|
4225 | 29 |
import sun.awt.AppContext; |
30 |
||
2 | 31 |
import javax.swing.*; |
32 |
import javax.swing.plaf.*; |
|
33 |
import javax.swing.plaf.basic.*; |
|
34 |
||
35 |
||
36 |
import java.awt.*; |
|
37 |
||
38 |
||
39 |
/** |
|
20169 | 40 |
* A Windows L&F implementation of LabelUI. This implementation |
2 | 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 |
||
4225 | 57 |
private static final Object METAL_LABEL_UI_KEY = new Object(); |
2 | 58 |
|
25178
dbab904451e9
8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents:
23010
diff
changeset
|
59 |
/** |
dbab904451e9
8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents:
23010
diff
changeset
|
60 |
* Returns an instance of {@code MetalLabelUI}. |
dbab904451e9
8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents:
23010
diff
changeset
|
61 |
* |
dbab904451e9
8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents:
23010
diff
changeset
|
62 |
* @param c a component |
dbab904451e9
8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents:
23010
diff
changeset
|
63 |
* @return an instance of {@code MetalLabelUI} |
dbab904451e9
8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents:
23010
diff
changeset
|
64 |
*/ |
2 | 65 |
public static ComponentUI createUI(JComponent c) { |
66 |
if (System.getSecurityManager() != null) { |
|
4225 | 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); |
|
73 |
} |
|
74 |
return safeMetalLabelUI; |
|
2 | 75 |
} |
4225 | 76 |
return metalLabelUI; |
2 | 77 |
} |
78 |
||
79 |
/** |
|
80 |
* Just paint the text gray (Label.disabledForeground) rather than |
|
81 |
* in the labels foreground color. |
|
82 |
* |
|
83 |
* @see #paint |
|
84 |
* @see #paintEnabledText |
|
85 |
*/ |
|
86 |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) |
|
87 |
{ |
|
88 |
int mnemIndex = l.getDisplayedMnemonicIndex(); |
|
89 |
g.setColor(UIManager.getColor("Label.disabledForeground")); |
|
90 |
SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex, |
|
91 |
textX, textY); |
|
92 |
} |
|
93 |
} |