From 3726908dbc8d205aa799f3f8b7cd47663f985141 Mon Sep 17 00:00:00 2001 From: peterz Date: Mon, 23 Mar 2009 14:09:32 +0300 Subject: [PATCH] 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 --- src/share/classes/javax/swing/UIManager.java | 32 ++++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/share/classes/javax/swing/UIManager.java b/src/share/classes/javax/swing/UIManager.java index 43476f2d6..bd6f6ac91 100644 --- a/src/share/classes/javax/swing/UIManager.java +++ b/src/share/classes/javax/swing/UIManager.java @@ -58,6 +58,8 @@ import sun.awt.OSInfo; 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 @@ public class UIManager implements Serializable 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 = "" ; 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)); } } } -- GitLab