提交 3726908d 编写于 作者: P peterz

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
上级 37a83cc9
......@@ -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 = "<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));
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册