OpenJDK / jdk / hs
changeset 2492:0ea97f5e5746
6653395: Default LAF is set to CrossPlatformLookAndFeel not SystemLookAndFeel
Summary: Swing now checks AppContext properties to determine default LAF name. This is needed for plugin to be able to set default LAF w/o loading Swing classes.
Reviewed-by: alexp, loneid
author | peterz |
---|---|
date | Mon, 23 Mar 2009 14:09:32 +0300 |
parents | 123954ad0034 |
children | 93a357c96600 |
files | jdk/src/share/classes/javax/swing/UIManager.java |
diffstat | 1 files changed, 22 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/share/classes/javax/swing/UIManager.java Tue Mar 17 16:06:14 2009 +0300 +++ b/jdk/src/share/classes/javax/swing/UIManager.java Mon Mar 23 14:09:32 2009 +0300 @@ -58,6 +58,8 @@ import sun.security.action.GetPropertyAction; import sun.swing.SwingUtilities2; import java.lang.reflect.Method; +import java.util.HashMap; +import sun.awt.AppContext; /** @@ -1323,19 +1325,29 @@ return; } - String metalLnf = getCrossPlatformLookAndFeelClassName(); - String lnfDefault = metalLnf; + // Try to get default LAF from system property, then from AppContext + // (6653395), then use cross-platform one by default. + String lafName = null; + HashMap lafData = + (HashMap) AppContext.getAppContext().remove("swing.lafdata"); + if (lafData != null) { + lafName = (String) lafData.remove("defaultlaf"); + } + if (lafName == null) { + lafName = getCrossPlatformLookAndFeelClassName(); + } + lafName = swingProps.getProperty(defaultLAFKey, lafName); - String lnfName = "<undefined>" ; try { - lnfName = swingProps.getProperty(defaultLAFKey, lnfDefault); - setLookAndFeel(lnfName); + setLookAndFeel(lafName); } catch (Exception e) { - try { - lnfName = swingProps.getProperty(defaultLAFKey, metalLnf); - setLookAndFeel(lnfName); - } catch (Exception e2) { - throw new Error("can't load " + lnfName); + throw new Error("Cannot load " + lafName); + } + + // Set any properties passed through AppContext (6653395). + if (lafData != null) { + for (Object key: lafData.keySet()) { + UIManager.put(key, lafData.get(key)); } } }