src/share/classes/java/awt/Toolkit.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -54,10 +54,11 @@
import sun.awt.HeadlessToolkit;
import sun.awt.NullComponentPeer;
import sun.awt.PeerEvent;
import sun.awt.SunToolkit;
+import sun.awt.AWTAccessor;
import sun.security.util.SecurityConstants;
import sun.util.CoreResourceBundleControl;
/**
@@ -1605,10 +1606,16 @@
* Support for I18N: any visible strings should be stored in
* sun.awt.resources.awt.properties. The ResourceBundle is stored
* here, so that only one copy is maintained.
*/
private static ResourceBundle resources;
+ private static ResourceBundle platformResources;
+
+ // called by platform toolkit
+ private static void setPlatformResources(ResourceBundle bundle) {
+ platformResources = bundle;
+ }
/**
* Initialize JNI field and method ids
*/
private static native void initIDs();
@@ -1648,10 +1655,17 @@
loaded = true;
}
}
static {
+ AWTAccessor.setToolkitAccessor(
+ new AWTAccessor.ToolkitAccessor() {
+ @Override
+ public void setPlatformResources(ResourceBundle bundle) {
+ Toolkit.setPlatformResources(bundle);
+ }
+ });
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
try {
resources =
@@ -1675,10 +1689,18 @@
/**
* Gets a property with the specified key and default.
* This method returns defaultValue if the property is not found.
*/
public static String getProperty(String key, String defaultValue) {
+ // first try platform specific bundle
+ if (platformResources != null) {
+ try {
+ return platformResources.getString(key);
+ } catch (MissingResourceException e) {}
+ }
+
+ // then shared one
if (resources != null) {
try {
return resources.getString(key);
}
catch (MissingResourceException e) {}