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.JInternalFrame; |
import javax.swing.JInternalFrame; |
45 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
49 |
extends BasicInternalFrameUI |
extends BasicInternalFrameUI |
50 |
{ |
{ |
51 |
|
|
52 |
// FIXME: maybe replace by a Map of instances when this becomes stateful |
/** The instances of MetalInternalFrameUI*/ |
53 |
/** The shared UI instance for JInternalFrames */ |
private static HashMap instances; |
|
private static MetalInternalFrameUI instance = null; |
|
54 |
|
|
55 |
/** |
/** |
56 |
* Constructs a new instance of MetalInternalFrameUI. |
* Constructs a new instance of MetalInternalFrameUI. |
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 MetalInternalFrameUI((JInternalFrame) component); |
instances = new HashMap(); |
74 |
|
|
75 |
|
|
76 |
|
Object o = instances.get(component); |
77 |
|
MetalInternalFrameUI instance; |
78 |
|
if (o == null) |
79 |
|
{ |
80 |
|
instance = new MetalInternalFrameUI((JInternalFrame) component); |
81 |
|
instances.put(component, instance); |
82 |
|
} |
83 |
|
else |
84 |
|
instance = (MetalInternalFrameUI) o; |
85 |
|
|
86 |
return instance; |
return instance; |
87 |
} |
} |
88 |
} |
} |