src/share/classes/sun/awt/SunToolkit.java
Print this page
*** 195,204 ****
--- 195,205 ----
public abstract SystemTrayPeer createSystemTray(SystemTray target);
public abstract boolean isTraySupported();
+ @SuppressWarnings("deprecation")
public abstract FontPeer getFontPeer(String name, int style);
public abstract RobotPeer createRobot(Robot target, GraphicsDevice screen)
throws AWTException;
*** 303,313 ****
appContext.put(POST_EVENT_QUEUE_KEY, postEventQueue);
return appContext;
}
! public static Field getField(final Class klass, final String fieldName) {
return AccessController.doPrivileged(new PrivilegedAction<Field>() {
public Field run() {
try {
Field field = klass.getDeclaredField(fieldName);
assert (field != null);
--- 304,314 ----
appContext.put(POST_EVENT_QUEUE_KEY, postEventQueue);
return appContext;
}
! public static Field getField(final Class<?> klass, final String fieldName) {
return AccessController.doPrivileged(new PrivilegedAction<Field>() {
public Field run() {
try {
Field field = klass.getDeclaredField(fieldName);
assert (field != null);
*** 323,334 ****
});
}
static void wakeupEventQueue(EventQueue q, boolean isShutdown){
if (wakeupMethod == null){
! wakeupMethod = (Method)AccessController.doPrivileged(new PrivilegedAction(){
! public Object run(){
try {
Method method = EventQueue.class.getDeclaredMethod("wakeup",new Class [] {Boolean.TYPE} );
if (method != null) {
method.setAccessible(true);
}
--- 324,335 ----
});
}
static void wakeupEventQueue(EventQueue q, boolean isShutdown){
if (wakeupMethod == null){
! wakeupMethod = AccessController.doPrivileged(new PrivilegedAction<Method>() {
! public Method run() {
try {
Method method = EventQueue.class.getDeclaredMethod("wakeup",new Class [] {Boolean.TYPE} );
if (method != null) {
method.setAccessible(true);
}
*** 384,395 ****
}
}
// Maps from non-Component/MenuComponent to AppContext.
// WeakHashMap<Component,AppContext>
! private static final Map appContextMap =
! Collections.synchronizedMap(new WeakHashMap());
/**
* Sets the appContext field of target. If target is not a Component or
* MenuComponent, this returns false.
*/
--- 385,396 ----
}
}
// Maps from non-Component/MenuComponent to AppContext.
// WeakHashMap<Component,AppContext>
! private static final Map<Object, AppContext> appContextMap =
! Collections.synchronizedMap(new WeakHashMap<Object, AppContext>());
/**
* Sets the appContext field of target. If target is not a Component or
* MenuComponent, this returns false.
*/
*** 435,445 ****
}
AppContext context = getAppContext(target);
if (context == null) {
// target is not a Component/MenuComponent, try the
// appContextMap.
! context = (AppContext)appContextMap.get(target);
}
return context;
}
/**
--- 436,446 ----
}
AppContext context = getAppContext(target);
if (context == null) {
// target is not a Component/MenuComponent, try the
// appContextMap.
! context = appContextMap.get(target);
}
return context;
}
/**
*** 517,529 ****
}
private static FocusTraversalPolicy createLayoutPolicy() {
FocusTraversalPolicy policy = null;
try {
! Class layoutPolicyClass =
Class.forName("javax.swing.LayoutFocusTraversalPolicy");
! policy = (FocusTraversalPolicy) layoutPolicyClass.newInstance();
}
catch (ClassNotFoundException e) {
assert false;
}
catch (InstantiationException e) {
--- 518,530 ----
}
private static FocusTraversalPolicy createLayoutPolicy() {
FocusTraversalPolicy policy = null;
try {
! Class<?> layoutPolicyClass =
Class.forName("javax.swing.LayoutFocusTraversalPolicy");
! policy = (FocusTraversalPolicy)layoutPolicyClass.newInstance();
}
catch (ClassNotFoundException e) {
assert false;
}
catch (InstantiationException e) {
*** 640,654 ****
/*
* Fixed 5064013: the InvocationEvent time should be equals
* the time of the ActionEvent
*/
public static void executeOnEventHandlerThread(Object target,
Runnable runnable,
final long when) {
! executeOnEventHandlerThread(new PeerEvent(target, runnable, PeerEvent.PRIORITY_EVENT){
! public long getWhen(){
return when;
}
});
}
--- 641,657 ----
/*
* Fixed 5064013: the InvocationEvent time should be equals
* the time of the ActionEvent
*/
+ @SuppressWarnings("serial")
public static void executeOnEventHandlerThread(Object target,
Runnable runnable,
final long when) {
! executeOnEventHandlerThread(
! new PeerEvent(target, runnable, PeerEvent.PRIORITY_EVENT) {
! public long getWhen() {
return when;
}
});
}
*** 725,738 ****
--- 728,743 ----
return new Dimension(getScreenWidth(), getScreenHeight());
}
protected abstract int getScreenWidth();
protected abstract int getScreenHeight();
+ @SuppressWarnings("deprecation")
public FontMetrics getFontMetrics(Font font) {
return FontDesignMetrics.getMetrics(font);
}
+ @SuppressWarnings("deprecation")
public String[] getFontList() {
String[] hardwiredFontList = {
Font.DIALOG, Font.SANS_SERIF, Font.SERIF, Font.MONOSPACED,
Font.DIALOG_INPUT
*** 1154,1167 ****
* Returns the locale in which the runtime was started.
*/
public static Locale getStartupLocale() {
if (startupLocale == null) {
String language, region, country, variant;
! language = (String) AccessController.doPrivileged(
new GetPropertyAction("user.language", "en"));
// for compatibility, check for old user.region property
! region = (String) AccessController.doPrivileged(
new GetPropertyAction("user.region"));
if (region != null) {
// region can be of form country, country_variant, or _variant
int i = region.indexOf('_');
if (i >= 0) {
--- 1159,1172 ----
* Returns the locale in which the runtime was started.
*/
public static Locale getStartupLocale() {
if (startupLocale == null) {
String language, region, country, variant;
! language = AccessController.doPrivileged(
new GetPropertyAction("user.language", "en"));
// for compatibility, check for old user.region property
! region = AccessController.doPrivileged(
new GetPropertyAction("user.region"));
if (region != null) {
// region can be of form country, country_variant, or _variant
int i = region.indexOf('_');
if (i >= 0) {
*** 1170,1182 ****
} else {
country = region;
variant = "";
}
} else {
! country = (String) AccessController.doPrivileged(
new GetPropertyAction("user.country", ""));
! variant = (String) AccessController.doPrivileged(
new GetPropertyAction("user.variant", ""));
}
startupLocale = new Locale(language, country, variant);
}
return startupLocale;
--- 1175,1187 ----
} else {
country = region;
variant = "";
}
} else {
! country = AccessController.doPrivileged(
new GetPropertyAction("user.country", ""));
! variant = AccessController.doPrivileged(
new GetPropertyAction("user.variant", ""));
}
startupLocale = new Locale(language, country, variant);
}
return startupLocale;
*** 1252,1262 ****
* Returns whether default toolkit needs the support of the xembed
* from embedding host(if any).
* @return <code>true</code>, if XEmbed is needed, <code>false</code> otherwise
*/
public static boolean needsXEmbed() {
! String noxembed = (String) AccessController.
doPrivileged(new GetPropertyAction("sun.awt.noxembed", "false"));
if ("true".equals(noxembed)) {
return false;
}
--- 1257,1267 ----
* Returns whether default toolkit needs the support of the xembed
* from embedding host(if any).
* @return <code>true</code>, if XEmbed is needed, <code>false</code> otherwise
*/
public static boolean needsXEmbed() {
! String noxembed = AccessController.
doPrivileged(new GetPropertyAction("sun.awt.noxembed", "false"));
if ("true".equals(noxembed)) {
return false;
}
*** 1464,1474 ****
|| comp instanceof TextArea
|| comp instanceof TextField
|| comp instanceof Window);
}
! public static Method getMethod(final Class clz, final String methodName, final Class[] params) {
Method res = null;
try {
res = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
public Method run() throws Exception {
Method m = clz.getDeclaredMethod(methodName, params);
--- 1469,1479 ----
|| comp instanceof TextArea
|| comp instanceof TextField
|| comp instanceof Window);
}
! public static Method getMethod(final Class<?> clz, final String methodName, final Class[] params) {
Method res = null;
try {
res = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
public Method run() throws Exception {
Method m = clz.getDeclaredMethod(methodName, params);
*** 1480,1499 ****
--- 1485,1508 ----
ex.printStackTrace();
}
return res;
}
+ @SuppressWarnings("serial")
public static class OperationTimedOut extends RuntimeException {
public OperationTimedOut(String msg) {
super(msg);
}
public OperationTimedOut() {
}
}
+
+ @SuppressWarnings("serial")
public static class InfiniteLoop extends RuntimeException {
}
+ @SuppressWarnings("serial")
public static class IllegalThreadException extends RuntimeException {
public IllegalThreadException(String msg) {
super(msg);
}
public IllegalThreadException() {
*** 1646,1655 ****
--- 1655,1665 ----
* events are processed (including paint events), and that if
* recursive events were generated, they are also processed.
* Should return <code>true</code> if more processing is
* necessary, <code>false</code> otherwise.
*/
+ @SuppressWarnings("serial")
protected final boolean waitForIdle(final long timeout) {
flushPendingEvents();
boolean queueWasEmpty = isEQEmpty();
queueEmpty = false;
eventDispatched = false;
*** 1829,1839 ****
useSystemAAFontSettings = true; /* initially set this true */
String systemAAFonts = null;
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
systemAAFonts =
! (String)AccessController.doPrivileged(
new GetPropertyAction("awt.useSystemAAFontSettings"));
}
if (systemAAFonts != null) {
useSystemAAFontSettings =
Boolean.valueOf(systemAAFonts).booleanValue();
--- 1839,1849 ----
useSystemAAFontSettings = true; /* initially set this true */
String systemAAFonts = null;
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
systemAAFonts =
! AccessController.doPrivileged(
new GetPropertyAction("awt.useSystemAAFontSettings"));
}
if (systemAAFonts != null) {
useSystemAAFontSettings =
Boolean.valueOf(systemAAFonts).booleanValue();
*** 1896,1906 ****
private static Method consumeNextKeyTypedMethod = null;
public static synchronized void consumeNextKeyTyped(KeyEvent keyEvent) {
if (consumeNextKeyTypedMethod == null) {
consumeNextKeyTypedMethod = getMethod(DefaultKeyboardFocusManager.class,
"consumeNextKeyTyped",
! new Class[] {KeyEvent.class});
}
try {
consumeNextKeyTypedMethod.invoke(KeyboardFocusManager.getCurrentKeyboardFocusManager(),
keyEvent);
} catch (IllegalAccessException iae) {
--- 1906,1916 ----
private static Method consumeNextKeyTypedMethod = null;
public static synchronized void consumeNextKeyTyped(KeyEvent keyEvent) {
if (consumeNextKeyTypedMethod == null) {
consumeNextKeyTypedMethod = getMethod(DefaultKeyboardFocusManager.class,
"consumeNextKeyTyped",
! new Class<?>[] {KeyEvent.class});
}
try {
consumeNextKeyTypedMethod.invoke(KeyboardFocusManager.getCurrentKeyboardFocusManager(),
keyEvent);
} catch (IllegalAccessException iae) {
*** 1928,1950 ****
/**
* Returns the value of the system property indicated by the specified key.
*/
public static String getSystemProperty(final String key) {
! return (String)AccessController.doPrivileged(new PrivilegedAction() {
! public Object run() {
return System.getProperty(key);
}
});
}
/**
* Returns the boolean value of the system property indicated by the specified key.
*/
protected static Boolean getBooleanSystemProperty(String key) {
! return Boolean.valueOf(AccessController.
! doPrivileged(new GetBooleanAction(key)));
}
private static Boolean sunAwtDisableMixing = null;
/**
--- 1938,1959 ----
/**
* Returns the value of the system property indicated by the specified key.
*/
public static String getSystemProperty(final String key) {
! return AccessController.doPrivileged(new PrivilegedAction<String>() {
! public String run() {
return System.getProperty(key);
}
});
}
/**
* Returns the boolean value of the system property indicated by the specified key.
*/
protected static Boolean getBooleanSystemProperty(String key) {
! return AccessController.doPrivileged(new GetBooleanAction(key));
}
private static Boolean sunAwtDisableMixing = null;
/**
*** 2013,2023 ****
* 1.0f (which means that it is translucent), {@code false} otherwise
* @see GraphicsDevice.WindowTranslucency#TRANSLUCENT
*/
public static boolean isContainingTopLevelTranslucent(Component c) {
Window w = getContainingWindow(c);
! return w != null && ((Window)w).getOpacity() < 1.0f;
}
/**
* Returns whether the native system requires using the peer.updateWindow()
* method to update the contents of a non-opaque window, or if usual
--- 2022,2032 ----
* 1.0f (which means that it is translucent), {@code false} otherwise
* @see GraphicsDevice.WindowTranslucency#TRANSLUCENT
*/
public static boolean isContainingTopLevelTranslucent(Component c) {
Window w = getContainingWindow(c);
! return w != null && w.getOpacity() < 1.0f;
}
/**
* Returns whether the native system requires using the peer.updateWindow()
* method to update the contents of a non-opaque window, or if usual
*** 2055,2072 ****
if (type == null) return false;
return isInstanceOf(obj.getClass(), type);
}
! private static boolean isInstanceOf(Class cls, String type) {
if (cls == null) return false;
if (cls.getName().equals(type)) {
return true;
}
! for (Class c : cls.getInterfaces()) {
if (c.getName().equals(type)) {
return true;
}
}
return isInstanceOf(cls.getSuperclass(), type);
--- 2064,2081 ----
if (type == null) return false;
return isInstanceOf(obj.getClass(), type);
}
! private static boolean isInstanceOf(Class<?> cls, String type) {
if (cls == null) return false;
if (cls.getName().equals(type)) {
return true;
}
! for (Class<?> c : cls.getInterfaces()) {
if (c.getName().equals(type)) {
return true;
}
}
return isInstanceOf(cls.getSuperclass(), type);