classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: fix javax.swing.plaf.metal.MetalScrollBarUI


From: Roman Kennke
Subject: [cp-patches] FYI: fix javax.swing.plaf.metal.MetalScrollBarUI
Date: Mon, 18 Apr 2005 12:25:54 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

I commit the attached patch:

2005-04-18  Roman Kennke  <address@hidden>

       * javax/swing/plaf/metal/MetalScrollBarUI.java:
       (createUI): Instances cannot be shared among JScrollPanes.

/Roman

Index: javax/swing/plaf/metal/MetalScrollBarUI.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java,v
retrieving revision 1.1
diff -u -r1.1 MetalScrollBarUI.java
--- javax/swing/plaf/metal/MetalScrollBarUI.java        14 Apr 2005 18:00:46 
-0000      1.1
+++ javax/swing/plaf/metal/MetalScrollBarUI.java        18 Apr 2005 10:23:14 
-0000
@@ -38,6 +38,8 @@
 
 package javax.swing.plaf.metal;
 
+import java.util.HashMap;
+
 import javax.swing.JComponent;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicScrollBarUI;
@@ -48,7 +50,7 @@
 
   // FIXME: maybe replace by a Map of instances when this becomes stateful
   /** The shared UI instance for JScrollBars. */
-  private static MetalScrollBarUI instance = null;
+  private static HashMap instances = null;
 
   /**
    * Constructs a new instance of MetalScrollBarUI.
@@ -67,8 +69,19 @@
    */
   public static ComponentUI createUI(JComponent component)
   {
-    if (instance == null)
-      instance = new MetalScrollBarUI();
+    if (instances == null)
+      instances = new HashMap();
+
+    Object o = instances.get(component);
+    MetalScrollBarUI instance;
+    if (o == null)
+      {
+       instance = new MetalScrollBarUI();
+       instances.put(component, instance);
+      }
+    else
+      instance = (MetalScrollBarUI) o;
+
     return instance;
   }
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]