author | lana |
Thu, 26 Dec 2013 12:04:16 -0800 | |
changeset 23010 | 6dadb192ad81 |
parent 11975 | d3620e28371c |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
11975
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, 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 com.sun.java.swing.plaf.windows; |
|
27 |
||
4225 | 28 |
import sun.awt.AppContext; |
29 |
||
2 | 30 |
import javax.swing.plaf.basic.*; |
31 |
import javax.swing.*; |
|
32 |
import javax.swing.plaf.*; |
|
33 |
||
34 |
import java.awt.*; |
|
35 |
||
36 |
||
37 |
/** |
|
38 |
* Windows rendition of the component. |
|
39 |
* <p> |
|
40 |
* <strong>Warning:</strong> |
|
41 |
* Serialized objects of this class will not be compatible with |
|
42 |
* future Swing releases. The current serialization support is appropriate |
|
43 |
* for short term storage or RMI between applications running the same |
|
44 |
* version of Swing. A future release of Swing will provide support for |
|
45 |
* long term persistence. |
|
46 |
*/ |
|
47 |
public class WindowsRadioButtonUI extends BasicRadioButtonUI |
|
48 |
{ |
|
4225 | 49 |
private static final Object WINDOWS_RADIO_BUTTON_UI_KEY = new Object(); |
2 | 50 |
|
51 |
protected int dashedRectGapX; |
|
52 |
protected int dashedRectGapY; |
|
53 |
protected int dashedRectGapWidth; |
|
54 |
protected int dashedRectGapHeight; |
|
55 |
||
56 |
protected Color focusColor; |
|
57 |
||
58 |
private boolean initialized = false; |
|
59 |
||
60 |
// ******************************** |
|
61 |
// Create PLAF |
|
62 |
// ******************************** |
|
63 |
public static ComponentUI createUI(JComponent c) { |
|
4225 | 64 |
AppContext appContext = AppContext.getAppContext(); |
65 |
WindowsRadioButtonUI windowsRadioButtonUI = |
|
66 |
(WindowsRadioButtonUI) appContext.get(WINDOWS_RADIO_BUTTON_UI_KEY); |
|
67 |
if (windowsRadioButtonUI == null) { |
|
68 |
windowsRadioButtonUI = new WindowsRadioButtonUI(); |
|
69 |
appContext.put(WINDOWS_RADIO_BUTTON_UI_KEY, windowsRadioButtonUI); |
|
70 |
} |
|
2 | 71 |
return windowsRadioButtonUI; |
72 |
} |
|
73 |
||
74 |
// ******************************** |
|
75 |
// Defaults |
|
76 |
// ******************************** |
|
77 |
public void installDefaults(AbstractButton b) { |
|
78 |
super.installDefaults(b); |
|
79 |
if(!initialized) { |
|
80 |
dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue(); |
|
81 |
dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue(); |
|
82 |
dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue(); |
|
83 |
dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue(); |
|
84 |
focusColor = UIManager.getColor(getPropertyPrefix() + "focus"); |
|
85 |
initialized = true; |
|
86 |
} |
|
87 |
if (XPStyle.getXP() != null) { |
|
88 |
LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE); |
|
89 |
} |
|
90 |
} |
|
91 |
||
11975
d3620e28371c
7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
5506
diff
changeset
|
92 |
protected void uninstallDefaults(AbstractButton b) { |
d3620e28371c
7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
5506
diff
changeset
|
93 |
super.uninstallDefaults(b); |
d3620e28371c
7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
5506
diff
changeset
|
94 |
initialized = false; |
d3620e28371c
7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
5506
diff
changeset
|
95 |
} |
d3620e28371c
7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
5506
diff
changeset
|
96 |
|
2 | 97 |
protected Color getFocusColor() { |
98 |
return focusColor; |
|
99 |
} |
|
100 |
||
101 |
// ******************************** |
|
102 |
// Paint Methods |
|
103 |
// ******************************** |
|
104 |
||
105 |
/** |
|
106 |
* Overridden method to render the text without the mnemonic |
|
107 |
*/ |
|
108 |
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) { |
|
109 |
WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset()); |
|
110 |
} |
|
111 |
||
112 |
||
113 |
protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){ |
|
114 |
g.setColor(getFocusColor()); |
|
115 |
BasicGraphicsUtils.drawDashedRect(g, textRect.x, textRect.y, textRect.width, textRect.height); |
|
116 |
} |
|
117 |
||
118 |
// ******************************** |
|
119 |
// Layout Methods |
|
120 |
// ******************************** |
|
121 |
public Dimension getPreferredSize(JComponent c) { |
|
122 |
Dimension d = super.getPreferredSize(c); |
|
123 |
||
124 |
/* Ensure that the width and height of the button is odd, |
|
125 |
* to allow for the focus line if focus is painted |
|
126 |
*/ |
|
127 |
AbstractButton b = (AbstractButton)c; |
|
128 |
if (d != null && b.isFocusPainted()) { |
|
129 |
if(d.width % 2 == 0) { d.width += 1; } |
|
130 |
if(d.height % 2 == 0) { d.height += 1; } |
|
131 |
} |
|
132 |
return d; |
|
133 |
} |
|
134 |
||
135 |
} |