summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2005-07-12 19:24:49 +0000
committerRoman Kennke <roman@kennke.org>2005-07-12 19:24:49 +0000
commitca9f8078a0ce11ac85ecafaf66bd0550192437e1 (patch)
tree8b441308e5b44dae5a283f2b5809fcc93da061f8
parenteb821b6d32c8752a66272d8fcbc92db90dd78db8 (diff)
downloadclasspath-ca9f8078a0ce11ac85ecafaf66bd0550192437e1.tar.gz
2005-07-12 Roman Kennke <roman@kennke.org>
* javax/swing/plaf/metal/MetalTreeUI.java (createUI): Return a different instance of MetalTreeUI for each JTree. The TreeUI is stateful, so a shared instance would not work.
-rw-r--r--ChangeLog7
-rw-r--r--javax/swing/plaf/metal/MetalTreeUI.java22
2 files changed, 24 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 981e0b203..cec360e2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2005-07-12 Roman Kennke <roman@kennke.org>
+ * javax/swing/plaf/metal/MetalTreeUI.java
+ (createUI): Return a different instance of MetalTreeUI for each
+ JTree. The TreeUI is stateful, so a shared instance would not
+ work.
+
+2005-07-12 Roman Kennke <roman@kennke.org>
+
* javax/swing/plaf/basic/BasicTreeUI.java
I accidentally introduced revalidate calls for repaint calls.
Reverted.
diff --git a/javax/swing/plaf/metal/MetalTreeUI.java b/javax/swing/plaf/metal/MetalTreeUI.java
index dabc96be6..d85d61c24 100644
--- a/javax/swing/plaf/metal/MetalTreeUI.java
+++ b/javax/swing/plaf/metal/MetalTreeUI.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.util.HashMap;
+
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTreeUI;
@@ -46,9 +48,8 @@ public class MetalTreeUI
extends BasicTreeUI
{
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for MetalTreeUIs */
- private static MetalTreeUI instance = null;
+ /** The UI instances for MetalTreeUIs */
+ private static HashMap instances = null;
/**
* Constructs a new instance of MetalTreeUI.
@@ -67,8 +68,19 @@ public class MetalTreeUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalTreeUI();
+ if (instances == null)
+ instances = new HashMap();
+
+ Object o = instances.get(component);
+ MetalTreeUI instance;
+ if (o == null)
+ {
+ instance = new MetalTreeUI();
+ instances.put(component, instance);
+ }
+ else
+ instance = (MetalTreeUI) o;
+
return instance;
}
}