38 |
|
|
39 |
package javax.swing.plaf.basic; |
package javax.swing.plaf.basic; |
40 |
|
|
41 |
|
import java.awt.Color; |
42 |
|
import java.awt.Dimension; |
43 |
import java.awt.Font; |
import java.awt.Font; |
44 |
import java.awt.Graphics; |
import java.awt.Graphics; |
45 |
import java.awt.Rectangle; |
import java.awt.Rectangle; |
95 |
b.setIcon(icon); |
b.setIcon(icon); |
96 |
if (b.getSelectedIcon() == null) |
if (b.getSelectedIcon() == null) |
97 |
b.setSelectedIcon(icon); |
b.setSelectedIcon(icon); |
98 |
|
if (b.getDisabledIcon() == null) |
99 |
|
b.setDisabledIcon(icon); |
100 |
|
if (b.getDisabledSelectedIcon() == null) |
101 |
|
b.setDisabledSelectedIcon(icon); |
102 |
} |
} |
103 |
|
|
104 |
/** |
/** |
145 |
g.setFont(f); |
g.setFont(f); |
146 |
|
|
147 |
Icon currentIcon = null; |
Icon currentIcon = null; |
148 |
if (b.isSelected()) |
if (b.isSelected() && b.isEnabled()) |
149 |
currentIcon = b.getSelectedIcon(); |
currentIcon = b.getSelectedIcon(); |
150 |
else |
else if (!b.isSelected() && b.isEnabled()) |
151 |
currentIcon = b.getIcon(); |
currentIcon = b.getIcon(); |
152 |
|
else if (b.isSelected() && !b.isEnabled()) |
153 |
|
currentIcon = b.getDisabledSelectedIcon(); |
154 |
|
else // (!b.isSelected() && !b.isEnabled()) |
155 |
|
currentIcon = b.getDisabledIcon(); |
156 |
|
|
157 |
SwingUtilities.calculateInnerArea(b, vr); |
SwingUtilities.calculateInnerArea(b, vr); |
158 |
String text = SwingUtilities.layoutCompoundLabel |
String text = SwingUtilities.layoutCompoundLabel |
167 |
} |
} |
168 |
if (text != null) |
if (text != null) |
169 |
paintText(g, b, tr, text); |
paintText(g, b, tr, text); |
170 |
paintFocus(g, b, vr, tr, ir); |
// TODO: Figure out what is the size parameter? |
171 |
|
if (b.hasFocus() && b.isFocusPainted() && b.isEnabled()) |
172 |
|
paintFocus(g, tr, null); |
173 |
|
} |
174 |
|
|
175 |
|
/** |
176 |
|
* Paints the focus indicator for JRadioButtons. |
177 |
|
* |
178 |
|
* @param g the graphics context |
179 |
|
* @param tr the rectangle for the text label |
180 |
|
* @param size the size (??) |
181 |
|
*/ |
182 |
|
// TODO: Figure out what for is the size parameter. |
183 |
|
protected void paintFocus(Graphics g, Rectangle tr, Dimension size) |
184 |
|
{ |
185 |
|
Color focusColor = UIManager.getColor(getPropertyPrefix() + ".focus"); |
186 |
|
Color saved = g.getColor(); |
187 |
|
g.setColor(focusColor); |
188 |
|
g.drawRect(tr.x, tr.y, tr.width, tr.height); |
189 |
|
g.setColor(saved); |
190 |
} |
} |
191 |
} |
} |