src/share/classes/sun/awt/SunToolkit.java
Print this page
@@ -195,10 +195,11 @@
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,11 +304,11 @@
appContext.put(POST_EVENT_QUEUE_KEY, postEventQueue);
return appContext;
}
- public static Field getField(final Class klass, final String fieldName) {
+ 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,12 +324,12 @@
});
}
static void wakeupEventQueue(EventQueue q, boolean isShutdown){
if (wakeupMethod == null){
- wakeupMethod = (Method)AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
+ 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,12 +385,12 @@
}
}
// Maps from non-Component/MenuComponent to AppContext.
// WeakHashMap<Component,AppContext>
- private static final Map appContextMap =
- Collections.synchronizedMap(new WeakHashMap());
+ 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,11 +436,11 @@
}
AppContext context = getAppContext(target);
if (context == null) {
// target is not a Component/MenuComponent, try the
// appContextMap.
- context = (AppContext)appContextMap.get(target);
+ context = appContextMap.get(target);
}
return context;
}
/**
@@ -517,13 +518,13 @@
}
private static FocusTraversalPolicy createLayoutPolicy() {
FocusTraversalPolicy policy = null;
try {
- Class layoutPolicyClass =
+ Class<?> layoutPolicyClass =
Class.forName("javax.swing.LayoutFocusTraversalPolicy");
- policy = (FocusTraversalPolicy) layoutPolicyClass.newInstance();
+ policy = (FocusTraversalPolicy)layoutPolicyClass.newInstance();
}
catch (ClassNotFoundException e) {
assert false;
}
catch (InstantiationException e) {
@@ -640,15 +641,17 @@
/*
* 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(){
+ executeOnEventHandlerThread(
+ new PeerEvent(target, runnable, PeerEvent.PRIORITY_EVENT) {
+ public long getWhen() {
return when;
}
});
}
@@ -725,14 +728,16 @@
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,14 +1159,14 @@
* 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(
+ language = AccessController.doPrivileged(
new GetPropertyAction("user.language", "en"));
// for compatibility, check for old user.region property
- region = (String) AccessController.doPrivileged(
+ 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,13 +1175,13 @@
} else {
country = region;
variant = "";
}
} else {
- country = (String) AccessController.doPrivileged(
+ country = AccessController.doPrivileged(
new GetPropertyAction("user.country", ""));
- variant = (String) AccessController.doPrivileged(
+ variant = AccessController.doPrivileged(
new GetPropertyAction("user.variant", ""));
}
startupLocale = new Locale(language, country, variant);
}
return startupLocale;
@@ -1252,11 +1257,11 @@
* 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.
+ String noxembed = AccessController.
doPrivileged(new GetPropertyAction("sun.awt.noxembed", "false"));
if ("true".equals(noxembed)) {
return false;
}
@@ -1464,11 +1469,11 @@
|| comp instanceof TextArea
|| comp instanceof TextField
|| comp instanceof Window);
}
- public static Method getMethod(final Class clz, final String methodName, final Class[] params) {
+ 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,20 +1485,24 @@
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,10 +1655,11 @@
* 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,11 +1839,11 @@
useSystemAAFontSettings = true; /* initially set this true */
String systemAAFonts = null;
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
systemAAFonts =
- (String)AccessController.doPrivileged(
+ AccessController.doPrivileged(
new GetPropertyAction("awt.useSystemAAFontSettings"));
}
if (systemAAFonts != null) {
useSystemAAFontSettings =
Boolean.valueOf(systemAAFonts).booleanValue();
@@ -1896,11 +1906,11 @@
private static Method consumeNextKeyTypedMethod = null;
public static synchronized void consumeNextKeyTyped(KeyEvent keyEvent) {
if (consumeNextKeyTypedMethod == null) {
consumeNextKeyTypedMethod = getMethod(DefaultKeyboardFocusManager.class,
"consumeNextKeyTyped",
- new Class[] {KeyEvent.class});
+ new Class<?>[] {KeyEvent.class});
}
try {
consumeNextKeyTypedMethod.invoke(KeyboardFocusManager.getCurrentKeyboardFocusManager(),
keyEvent);
} catch (IllegalAccessException iae) {
@@ -1928,23 +1938,22 @@
/**
* 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 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 Boolean.valueOf(AccessController.
- doPrivileged(new GetBooleanAction(key)));
+ return AccessController.doPrivileged(new GetBooleanAction(key));
}
private static Boolean sunAwtDisableMixing = null;
/**
@@ -2013,11 +2022,11 @@
* 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;
+ 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,18 +2064,18 @@
if (type == null) return false;
return isInstanceOf(obj.getClass(), type);
}
- private static boolean isInstanceOf(Class cls, String 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()) {
+ for (Class<?> c : cls.getInterfaces()) {
if (c.getName().equals(type)) {
return true;
}
}
return isInstanceOf(cls.getSuperclass(), type);