38 |
|
|
39 |
package javax.swing.plaf.metal; |
package javax.swing.plaf.metal; |
40 |
|
|
41 |
|
import java.awt.Color; |
42 |
|
|
43 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
44 |
|
import javax.swing.UIDefaults; |
45 |
|
import javax.swing.UIManager; |
46 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
47 |
import javax.swing.plaf.basic.BasicToggleButtonUI; |
import javax.swing.plaf.basic.BasicToggleButtonUI; |
48 |
|
|
50 |
extends BasicToggleButtonUI |
extends BasicToggleButtonUI |
51 |
{ |
{ |
52 |
|
|
53 |
// FIXME: maybe replace by a Map of instances when this becomes stateful |
/** The color for the focus border. */ |
54 |
|
protected Color focusColor; |
55 |
|
|
56 |
|
/** The color that indicates a selected button. */ |
57 |
|
protected Color selectColor; |
58 |
|
|
59 |
|
/** The color for disabled button labels. */ |
60 |
|
protected Color disabledTextColor; |
61 |
|
|
62 |
/** The shared UI instance for MetalToggleButtonUIs */ |
/** The shared UI instance for MetalToggleButtonUIs */ |
63 |
private static MetalToggleButtonUI instance = null; |
private static MetalToggleButtonUI instance = null; |
64 |
|
|
68 |
public MetalToggleButtonUI() |
public MetalToggleButtonUI() |
69 |
{ |
{ |
70 |
super(); |
super(); |
71 |
|
focusColor = getFocusColor(); |
72 |
|
selectColor = getSelectColor(); |
73 |
|
disabledTextColor = getDisabledTextColor(); |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
/** |
78 |
|
* Returns the color for the focus border. |
79 |
|
* |
80 |
|
* @return the color for the focus border |
81 |
|
*/ |
82 |
|
protected Color getFocusColor() |
83 |
|
{ |
84 |
|
UIDefaults def = UIManager.getLookAndFeelDefaults(); |
85 |
|
return def.getColor(getPropertyPrefix() + ".focus"); |
86 |
|
} |
87 |
|
|
88 |
|
/** |
89 |
|
* Returns the color that indicates a selected button. |
90 |
|
* |
91 |
|
* @return the color that indicates a selected button |
92 |
|
*/ |
93 |
|
protected Color getSelectColor() |
94 |
|
{ |
95 |
|
UIDefaults def = UIManager.getLookAndFeelDefaults(); |
96 |
|
return def.getColor(getPropertyPrefix() + ".select"); |
97 |
|
} |
98 |
|
|
99 |
|
/** |
100 |
|
* Returns the color for the text label of disabled buttons. |
101 |
|
* |
102 |
|
* @return the color for the text label of disabled buttons |
103 |
|
*/ |
104 |
|
protected Color getDisabledTextColor() |
105 |
|
{ |
106 |
|
UIDefaults def = UIManager.getLookAndFeelDefaults(); |
107 |
|
return def.getColor(getPropertyPrefix() + ".disabledText"); |
108 |
} |
} |
109 |
|
|
110 |
/** |
/** |