[cp-patches] FYI: JComponent default locale fix

David Gilbert david.gilbert at object-refinery.com
Thu Jun 29 14:47:07 UTC 2006


This patch (committed) fixes a failing test in Intel's test suite:

2006-06-29  David Gilbert  <david.gilbert at object-refinery.com>

	* javax/swing/JComponent.java
	(JComponent()): Initialize the locale here, not the default locale,
	(getDefaultLocale): If null, return Locale.getDefault(),
	(setDefaultLocale): Added API docs.

Regards,

Dave
-------------- next part --------------
Index: javax/swing/JComponent.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.136
diff -u -r1.136 JComponent.java
--- javax/swing/JComponent.java	28 Jun 2006 16:25:40 -0000	1.136
+++ javax/swing/JComponent.java	29 Jun 2006 14:24:41 -0000
@@ -72,7 +72,6 @@
 import java.beans.VetoableChangeSupport;
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.EventListener;
 import java.util.Hashtable;
 import java.util.Locale;
@@ -812,7 +811,7 @@
   {
     super();
     setDropTarget(new DropTarget());
-    defaultLocale = Locale.getDefault();
+    setLocale(getDefaultLocale());
     debugGraphicsOptions = DebugGraphics.NONE_OPTION;
     setRequestFocusEnabled(true);
   }
@@ -3207,11 +3206,29 @@
     // Nothing to do here.
   }
 
+  /**
+   * Returns the locale used as the default for all new components.  The 
+   * default value is {@link Locale#getDefault()} (that is, the platform
+   * default locale).
+   * 
+   * @return The locale (never <code>null</code>).
+   * 
+   * @see #setDefaultLocale(Locale)
+   */
   public static Locale getDefaultLocale()
   {
+    if (defaultLocale == null)
+      defaultLocale = Locale.getDefault();
     return defaultLocale;
   }
   
+  /**
+   * Sets the locale to be used as the default for all new components.  If this
+   * is set to <code>null</code>, the {@link #getDefaultLocale()} method will
+   * return the platform default locale.
+   * 
+   * @param l  the locale (<code>null</code> permitted).
+   */
   public static void setDefaultLocale(Locale l)
   {
     defaultLocale = l;


More information about the Classpath-patches mailing list