24 */ |
24 */ |
25 |
25 |
26 package javax.swing.plaf.metal; |
26 package javax.swing.plaf.metal; |
27 |
27 |
28 import sun.swing.SwingUtilities2; |
28 import sun.swing.SwingUtilities2; |
|
29 import sun.awt.AppContext; |
|
30 |
29 import javax.swing.*; |
31 import javax.swing.*; |
30 import javax.swing.border.*; |
32 import javax.swing.border.*; |
31 import javax.swing.plaf.basic.*; |
33 import javax.swing.plaf.basic.*; |
32 import java.awt.*; |
34 import java.awt.*; |
33 import java.awt.event.*; |
35 import java.awt.event.*; |
47 * Please see {@link java.beans.XMLEncoder}. |
49 * Please see {@link java.beans.XMLEncoder}. |
48 * |
50 * |
49 * @author Tom Santos |
51 * @author Tom Santos |
50 */ |
52 */ |
51 public class MetalButtonUI extends BasicButtonUI { |
53 public class MetalButtonUI extends BasicButtonUI { |
52 |
|
53 private final static MetalButtonUI metalButtonUI = new MetalButtonUI(); |
|
54 |
|
55 // NOTE: These are not really needed, but at this point we can't pull |
54 // NOTE: These are not really needed, but at this point we can't pull |
56 // them. Their values are updated purely for historical reasons. |
55 // them. Their values are updated purely for historical reasons. |
57 protected Color focusColor; |
56 protected Color focusColor; |
58 protected Color selectColor; |
57 protected Color selectColor; |
59 protected Color disabledTextColor; |
58 protected Color disabledTextColor; |
60 |
59 |
|
60 private static final Object METAL_BUTTON_UI_KEY = new Object(); |
|
61 |
61 // ******************************** |
62 // ******************************** |
62 // Create PLAF |
63 // Create PLAF |
63 // ******************************** |
64 // ******************************** |
64 public static ComponentUI createUI(JComponent c) { |
65 public static ComponentUI createUI(JComponent c) { |
|
66 AppContext appContext = AppContext.getAppContext(); |
|
67 MetalButtonUI metalButtonUI = |
|
68 (MetalButtonUI) appContext.get(METAL_BUTTON_UI_KEY); |
|
69 if (metalButtonUI == null) { |
|
70 metalButtonUI = new MetalButtonUI(); |
|
71 appContext.put(METAL_BUTTON_UI_KEY, metalButtonUI); |
|
72 } |
65 return metalButtonUI; |
73 return metalButtonUI; |
66 } |
74 } |
67 |
75 |
68 // ******************************** |
76 // ******************************** |
69 // Install |
77 // Install |