Here comes the UIManager fix that I prepared with the last two patches.
I noticed that the UIManager has an additional 'layer' of settings, I
call this user settings. You can access them via the put() and the
various getXXX() methods of UIManager. The thing is, if you set
something via UIManager.put(), this settings is managed independent of
the current L&F, this means you still have this setting after a L&F
change. Only if there is no user setting for a specific key, then this
key is looked up in the UI defaults. This also implies that the UI
classes must not use UIManager.getLookAndFeelDefaults().getXXX() but
instead UIManager.getXXX(), so that they can 'see' the user settings.
2005-11-15 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/UIManager.java
(userUIDefaults): New field.
(get(Object)): Respect the user UI settings.
(get(Object,Locale)): Respect the user UI settings.
(getBoolean(Object)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getBoolean(Object,Locale)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getBorder(Object)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getBorder(Object,Locale)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getColor(Object)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getColor(Object,Locale)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getDimension(Object)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getDimension(Object,Locale)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getFont(Object)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getFont(Object,Locale)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getIcon(Object)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getIcon(Object,Locale)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getInsets(Object)): Call get() instead of
getLookAndFeelDefaults().getInsets() in order to respect the user UI
settings.
(getInsets(Object,Locale)): Call get() instead of
getLookAndFeelDefaults().getInsets() in order to respect the user UI
settings.
(getInt(Object)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getInt(Object,Locale)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getString(Object)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getString(Object,Locale)): Call get() instead of
getLookAndFeelDefaults().get() in order to respect the user UI
settings.
(getUI(JComponent)): Respect the user UI settings.
(put): Put key/value into user UI settings.
/Roman
Index: javax/swing/UIManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/UIManager.java,v
retrieving revision 1.28
diff -u -r1.28 UIManager.java
--- javax/swing/UIManager.java 2 Nov 2005 21:23:46 -0000 1.28
+++ javax/swing/UIManager.java 15 Nov 2005 21:07:59 -0000
@@ -132,6 +132,11 @@
static UIDefaults currentUIDefaults;
+ /**
+ * UIDefaults set by the user.
+ */
+ static UIDefaults userUIDefaults;
+
/** Property change listener mechanism. */
static SwingPropertyChangeSupport listeners
= new SwingPropertyChangeSupport(UIManager.class);
@@ -305,7 +310,12 @@
*/
public static Object get(Object key)
{
- return getLookAndFeelDefaults().get(key);
+ Object val = null;
+ if (userUIDefaults != null)
+ val = userUIDefaults.get(key);
+ if (val == null)
+ val = getLookAndFeelDefaults().get(key);
+ return val;
}
/**
@@ -318,7 +328,12 @@
*/
public static Object get(Object key, Locale locale)
{
- return getLookAndFeelDefaults().get(key ,locale);
+ Object val = null;
+ if (userUIDefaults != null)
+ val = userUIDefaults.get(key, locale);
+ if (val == null)
+ val = getLookAndFeelDefaults().get(key, locale);
+ return val;
}
/**
@@ -329,7 +344,7 @@
*/
public static boolean getBoolean(Object key)
{
- Boolean value = (Boolean) getLookAndFeelDefaults().get(key);
+ Boolean value = (Boolean) get(key);
return value != null ? value.booleanValue() : false;
}
@@ -341,7 +356,7 @@
*/
public static boolean getBoolean(Object key, Locale locale)
{
- Boolean value = (Boolean) getLookAndFeelDefaults().get(key, locale);
+ Boolean value = (Boolean) get(key, locale);
return value != null ? value.booleanValue() : false;
}
@@ -350,7 +365,7 @@
*/
public static Border getBorder(Object key)
{
- return (Border) getLookAndFeelDefaults().get(key);
+ return (Border) get(key);
}
/**
@@ -360,7 +375,7 @@
*/
public static Border getBorder(Object key, Locale locale)
{
- return (Border) getLookAndFeelDefaults().get(key, locale);
+ return (Border) get(key, locale);
}
/**
@@ -368,7 +383,7 @@
*/
public static Color getColor(Object key)
{
- return (Color) getLookAndFeelDefaults().get(key);
+ return (Color) get(key);
}
/**
@@ -376,7 +391,7 @@
*/
public static Color getColor(Object key, Locale locale)
{
- return (Color) getLookAndFeelDefaults().get(key);
+ return (Color) get(key);
}
/**
@@ -405,7 +420,7 @@
*/
public static Dimension getDimension(Object key)
{
- return (Dimension) getLookAndFeelDefaults().get(key);
+ return (Dimension) get(key);
}
/**
@@ -413,7 +428,7 @@
*/
public static Dimension getDimension(Object key, Locale locale)
{
- return (Dimension) getLookAndFeelDefaults().get(key, locale);
+ return (Dimension) get(key, locale);
}
/**
@@ -426,7 +441,7 @@
*/
public static Font getFont(Object key)
{
- return (Font) getLookAndFeelDefaults().get(key);
+ return (Font) get(key);
}
/**
@@ -439,7 +454,7 @@
*/
public static Font getFont(Object key, Locale locale)
{
- return (Font) getLookAndFeelDefaults().get(key ,locale);
+ return (Font) get(key ,locale);
}
/**
@@ -447,7 +462,7 @@
*/
public static Icon getIcon(Object key)
{
- return (Icon) getLookAndFeelDefaults().get(key);
+ return (Icon) get(key);
}
/**
@@ -455,7 +470,7 @@
*/
public static Icon getIcon(Object key, Locale locale)
{
- return (Icon) getLookAndFeelDefaults().get(key, locale);
+ return (Icon) get(key, locale);
}
/**
@@ -463,7 +478,11 @@
*/
public static Insets getInsets(Object key)
{
- return getLookAndFeelDefaults().getInsets(key);
+ Object o = get(key);
+ if (o instanceof Insets)
+ return (Insets) o;
+ else
+ return null;
}
/**
@@ -471,7 +490,11 @@
*/
public static Insets getInsets(Object key, Locale locale)
{
- return getLookAndFeelDefaults().getInsets(key, locale);
+ Object o = get(key, locale);
+ if (o instanceof Insets)
+ return (Insets) o;
+ else
+ return null;
}
/**
@@ -487,7 +510,7 @@
public static int getInt(Object key)
{
- Integer x = (Integer) getLookAndFeelDefaults().get(key);
+ Integer x = (Integer) get(key);
if (x == null)
return 0;
return x.intValue();
@@ -495,7 +518,7 @@
public static int getInt(Object key, Locale locale)
{
- Integer x = (Integer) getLookAndFeelDefaults().get(key, locale);
+ Integer x = (Integer) get(key, locale);
if (x == null)
return 0;
return x.intValue();
@@ -529,7 +552,7 @@
*/
public static String getString(Object key)
{
- return (String) getLookAndFeelDefaults().get(key);
+ return (String) get(key);
}
/**
@@ -537,7 +560,7 @@
*/
public static String getString(Object key, Locale locale)
{
- return (String) getLookAndFeelDefaults().get(key, locale);
+ return (String) get(key, locale);
}
/**
@@ -562,7 +585,13 @@
*/
public static ComponentUI getUI(JComponent target)
{
- return getLookAndFeelDefaults().getUI(target);
+ ComponentUI ui = null;
+ if (userUIDefaults != null
+ && userUIDefaults.get(target.getUIClassID()) != null)
+ ui = userUIDefaults.getUI(target);
+ if (ui == null)
+ ui = currentUIDefaults.getUI(target);
+ return ui;
}
/**
@@ -591,7 +620,11 @@
*/
public static Object put(Object key, Object value)
{
- return getLookAndFeelDefaults().put(key,value);
+ Object old = get(key);
+ if (userUIDefaults == null)
+ userUIDefaults = new UIDefaults();
+ userUIDefaults.put(key, value);
+ return old;
}
/**
@@ -617,7 +650,6 @@
{
if (newLookAndFeel != null && ! newLookAndFeel.isSupportedLookAndFeel())
throw new UnsupportedLookAndFeelException(newLookAndFeel.getName());
-
LookAndFeel oldLookAndFeel = currentLookAndFeel;
if (oldLookAndFeel != null)
oldLookAndFeel.uninitialize();
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches