7110683: Issues with some KeyboardFocusManager method
authorskoppar
Thu Dec 22 09:39:24 2011 -0800 (17 months ago)
changeset 554e05eb7bee1ce
parent 553bfaa99d5bef8
child 5553c11966c3da3
7110683: Issues with some KeyboardFocusManager method
7116384: backout the unallowed changes in the KeyboardFocusManager.java javadoc
Reviewed-by: ant
src/share/classes/java/awt/KeyboardFocusManager.java
--- a/src/share/classes/java/awt/KeyboardFocusManager.java Tue Dec 20 12:37:24 2011 -0800
+++ b/src/share/classes/java/awt/KeyboardFocusManager.java Thu Dec 22 09:39:24 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -476,14 +476,8 @@ public abstract class KeyboardFocusManag
*/
protected Component getGlobalFocusOwner() throws SecurityException {
synchronized (KeyboardFocusManager.class) {
- if (this == getCurrentKeyboardFocusManager()) {
- return focusOwner;
- } else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
- }
- throw new SecurityException(notPrivileged);
- }
+ checkCurrentKFMSecurity();
+ return focusOwner;
}
}
@@ -517,6 +511,7 @@ public abstract class KeyboardFocusManag
if (focusOwner == null || focusOwner.isFocusable()) {
synchronized (KeyboardFocusManager.class) {
+ checkCurrentKFMSecurity();
oldFocusOwner = getFocusOwner();
try {
@@ -566,6 +561,10 @@ public abstract class KeyboardFocusManag
* @see java.awt.event.FocusEvent#FOCUS_LOST
*/
public void clearGlobalFocusOwner() {
+ synchronized (KeyboardFocusManager.class) {
+ checkCurrentKFMSecurity();
+ }
+
if (!GraphicsEnvironment.isHeadless()) {
// Toolkit must be fully initialized, otherwise
// _clearGlobalFocusOwner will crash or throw an exception
@@ -645,14 +644,8 @@ public abstract class KeyboardFocusManag
throws SecurityException
{
synchronized (KeyboardFocusManager.class) {
- if (this == getCurrentKeyboardFocusManager()) {
- return permanentFocusOwner;
- } else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
- }
- throw new SecurityException(notPrivileged);
- }
+ checkCurrentKFMSecurity();
+ return permanentFocusOwner;
}
}
@@ -688,6 +681,7 @@ public abstract class KeyboardFocusManag
if (permanentFocusOwner == null || permanentFocusOwner.isFocusable()) {
synchronized (KeyboardFocusManager.class) {
+ checkCurrentKFMSecurity();
oldPermanentFocusOwner = getPermanentFocusOwner();
try {
@@ -753,14 +747,8 @@ public abstract class KeyboardFocusManag
*/
protected Window getGlobalFocusedWindow() throws SecurityException {
synchronized (KeyboardFocusManager.class) {
- if (this == getCurrentKeyboardFocusManager()) {
- return focusedWindow;
- } else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
- }
- throw new SecurityException(notPrivileged);
- }
+ checkCurrentKFMSecurity();
+ return focusedWindow;
}
}
@@ -791,6 +779,7 @@ public abstract class KeyboardFocusManag
if (focusedWindow == null || focusedWindow.isFocusableWindow()) {
synchronized (KeyboardFocusManager.class) {
+ checkCurrentKFMSecurity();
oldFocusedWindow = getFocusedWindow();
try {
@@ -857,14 +846,8 @@ public abstract class KeyboardFocusManag
*/
protected Window getGlobalActiveWindow() throws SecurityException {
synchronized (KeyboardFocusManager.class) {
- if (this == getCurrentKeyboardFocusManager()) {
- return activeWindow;
- } else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
- }
- throw new SecurityException(notPrivileged);
- }
+ checkCurrentKFMSecurity();
+ return activeWindow;
}
}
@@ -893,6 +876,7 @@ public abstract class KeyboardFocusManag
protected void setGlobalActiveWindow(Window activeWindow) {
Window oldActiveWindow;
synchronized (KeyboardFocusManager.class) {
+ checkCurrentKFMSecurity();
oldActiveWindow = getActiveWindow();
if (focusLog.isLoggable(Level.FINER)) {
focusLog.log(Level.FINER, "Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
@@ -1187,14 +1171,8 @@ public abstract class KeyboardFocusManag
throws SecurityException
{
synchronized (KeyboardFocusManager.class) {
- if (this == getCurrentKeyboardFocusManager()) {
- return currentFocusCycleRoot;
- } else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
- }
- throw new SecurityException(notPrivileged);
- }
+ checkCurrentKFMSecurity();
+ return currentFocusCycleRoot;
}
}
@@ -1218,6 +1196,7 @@ public abstract class KeyboardFocusManag
Container oldFocusCycleRoot;
synchronized (KeyboardFocusManager.class) {
+ checkCurrentKFMSecurity();
oldFocusCycleRoot = getCurrentFocusCycleRoot();
currentFocusCycleRoot = newFocusCycleRoot;
}
@@ -3102,4 +3081,14 @@ public abstract class KeyboardFocusManag
: null;
}
}
+
+ private void checkCurrentKFMSecurity() {
+ if (this != getCurrentKeyboardFocusManager()) {
+ if (focusLog.isLoggable(Level.FINER)) {
+ focusLog.finer("This manager is " + this +
+ ", current is " + getCurrentKeyboardFocusManager());
+ }
+ throw new SecurityException(notPrivileged);
+ }
+ }
}