38 |
|
|
39 |
package javax.swing.plaf.metal; |
package javax.swing.plaf.metal; |
40 |
|
|
41 |
|
import java.util.HashMap; |
42 |
|
|
43 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
44 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
45 |
import javax.swing.plaf.basic.BasicScrollBarUI; |
import javax.swing.plaf.basic.BasicScrollBarUI; |
50 |
|
|
51 |
// FIXME: maybe replace by a Map of instances when this becomes stateful |
// FIXME: maybe replace by a Map of instances when this becomes stateful |
52 |
/** The shared UI instance for JScrollBars. */ |
/** The shared UI instance for JScrollBars. */ |
53 |
private static MetalScrollBarUI instance = null; |
private static HashMap instances = null; |
54 |
|
|
55 |
/** |
/** |
56 |
* Constructs a new instance of MetalScrollBarUI. |
* Constructs a new instance of MetalScrollBarUI. |
69 |
*/ |
*/ |
70 |
public static ComponentUI createUI(JComponent component) |
public static ComponentUI createUI(JComponent component) |
71 |
{ |
{ |
72 |
if (instance == null) |
if (instances == null) |
73 |
instance = new MetalScrollBarUI(); |
instances = new HashMap(); |
74 |
|
|
75 |
|
Object o = instances.get(component); |
76 |
|
MetalScrollBarUI instance; |
77 |
|
if (o == null) |
78 |
|
{ |
79 |
|
instance = new MetalScrollBarUI(); |
80 |
|
instances.put(component, instance); |
81 |
|
} |
82 |
|
else |
83 |
|
instance = (MetalScrollBarUI) o; |
84 |
|
|
85 |
return instance; |
return instance; |
86 |
} |
} |
87 |
} |
} |