classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: MetalTabbedPaneUI fix


From: Roman Kennke
Subject: [cp-patches] FYI: MetalTabbedPaneUI fix
Date: Fri, 15 Apr 2005 11:03:45 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

The following fix lets MetalTabbedPaneUI create one instance of itself instead of sharing a singleton.

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

       * javax/swing/plaf/metal/MetalTabbedPaneUI.java
       (createUI): Create one MetalTabbedPaneUI per Component instead
       of sharing one instance.


/Roman

Index: javax/swing/plaf/metal/MetalTabbedPaneUI.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java,v
retrieving revision 1.2
diff -u -r1.2 MetalTabbedPaneUI.java
--- javax/swing/plaf/metal/MetalTabbedPaneUI.java       14 Apr 2005 13:58:51 
-0000      1.2
+++ javax/swing/plaf/metal/MetalTabbedPaneUI.java       15 Apr 2005 09:00:03 
-0000
@@ -38,6 +38,8 @@
 
 package javax.swing.plaf.metal;
 
+import java.util.HashMap;
+import java.util.Map;
 import javax.swing.JComponent;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicTabbedPaneUI;
@@ -46,9 +48,8 @@
   extends BasicTabbedPaneUI
 {
 
-  // FIXME: maybe replace by a Map of instances when this becomes stateful
   /** The shared UI instance for JTabbedPanes. */
-  private static MetalTabbedPaneUI instance = null;
+  private static Map instances = null;
 
   /**
    * Constructs a new instance of MetalTabbedPaneUI.
@@ -67,8 +68,19 @@
    */
   public static ComponentUI createUI(JComponent component)
   {
-    if (instance == null)
-      instance = new MetalTabbedPaneUI();
+    if (instances == null)
+      instances = new HashMap();
+
+    Object o = instances.get(component);
+    MetalTabbedPaneUI instance;
+    if (o == null)
+      {
+       instance = new MetalTabbedPaneUI();
+       instances.put(component, instance);
+      }
+    else
+      instance = (MetalTabbedPaneUI) o;
+
     return instance;
   }
 }

reply via email to

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