classpath-patches
[Top][All Lists]
Advanced

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

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


From: Roman Kennke
Subject: [cp-patches] FYI: fix for javax.swing.plaf.metal.MetalSplitPaneUI
Date: Mon, 30 May 2005 16:02:00 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

Hi,

the MetalSplitPaneUI had the bug that it shared one instance of itseflf between multiple instances of JSplitPane. This is hereby fixed.

2005-05-30  Roman Kennke  <address@hidden>

       * javax/swing/plaf/metal/MetalSplitPaneUI.java:
       (createUI): Do not share one instance of MetalSplitPaneUI
       between multiple JSplitPanes.


/Roman

Index: javax/swing/plaf/metal/MetalSplitPaneUI.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java,v
retrieving revision 1.1
diff -u -r1.1 MetalSplitPaneUI.java
--- javax/swing/plaf/metal/MetalSplitPaneUI.java        14 Apr 2005 18:00:46 
-0000      1.1
+++ javax/swing/plaf/metal/MetalSplitPaneUI.java        30 May 2005 13:58:10 
-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.BasicSplitPaneUI;
@@ -46,9 +48,8 @@
   extends BasicSplitPaneUI
 {
 
-  // FIXME: maybe replace by a Map of instances when this becomes stateful
-  /** The shared UI instance for MetalSplitPaneUIs */
-  private static MetalSplitPaneUI instance = null;
+  /** The UI instances for MetalSplitPaneUIs */
+  private static HashMap instances;
 
   /**
    * Constructs a new instance of MetalSplitPaneUI.
@@ -67,8 +68,19 @@
    */
   public static ComponentUI createUI(JComponent component)
   {
-    if (instance == null)
-      instance = new MetalSplitPaneUI();
+    if (instances == null)
+      instances = new HashMap();
+
+    Object o = instances.get(component);
+    MetalSplitPaneUI instance;
+    if (o == null)
+      {
+       instance = new MetalSplitPaneUI();
+       instances.put(component, instance);
+      }
+    else
+      instance = (MetalSplitPaneUI) o;
+
     return instance;
   }
 }

reply via email to

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