< prev index next >

src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java

Print this page

        

@@ -38,11 +38,10 @@
 import sun.util.logging.PlatformLogger;
 
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
 import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
 import sun.awt.TimedWindowEvent;
 
 /**
  * The default KeyboardFocusManager for AWT applications. Focus traversal is
  * done in response to a Component's focus traversal keys, and using a

@@ -163,17 +162,17 @@
     }
     private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                                    boolean clearOnFailure)
     {
         if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
-            toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
+            toFocus.requestFocus(false, FocusEvent.Cause.ROLLBACK))
         {
             return true;
         } else {
             Component nextFocus = toFocus.getNextFocusCandidate();
             if (nextFocus != null && nextFocus != vetoedComponent &&
-                nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
+                nextFocus.requestFocusInWindow(FocusEvent.Cause.ROLLBACK))
             {
                 return true;
             } else if (clearOnFailure) {
                 clearGlobalFocusOwnerPriv();
                 return true;

@@ -429,17 +428,17 @@
                     if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
                         focusLog.finer("tempLost {0}, toFocus {1}",
                                        tempLost, toFocus);
                     }
                     if (tempLost != null) {
-                        tempLost.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
+                        tempLost.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
                     }
 
                     if (toFocus != null && toFocus != tempLost) {
                         // If there is a component which requested focus when this window
                         // was inactive it expects to receive focus after activation.
-                        toFocus.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
+                        toFocus.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
                     }
                 }
 
                 Window realOppositeWindow = this.realOppositeWindowWR.get();
                 if (realOppositeWindow != we.getOppositeWindow()) {

@@ -488,12 +487,10 @@
                 return typeAheadAssertions(newActiveWindow, we);
             }
 
             case FocusEvent.FOCUS_GAINED: {
                 FocusEvent fe = (FocusEvent)e;
-                CausedFocusEvent.Cause cause = (fe instanceof CausedFocusEvent) ?
-                    ((CausedFocusEvent)fe).getCause() : CausedFocusEvent.Cause.UNKNOWN;
                 Component oldFocusOwner = getGlobalFocusOwner();
                 Component newFocusOwner = fe.getComponent();
                 if (oldFocusOwner == newFocusOwner) {
                     if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
                         focusLog.fine("Skipping {0} because focus owner is the same", e);

@@ -507,14 +504,14 @@
                 // If there exists a current focus owner, then notify it that
                 // it has lost focus.
                 if (oldFocusOwner != null) {
                     boolean isEventDispatched =
                         sendMessage(oldFocusOwner,
-                                    new CausedFocusEvent(oldFocusOwner,
+                                    new FocusEvent(oldFocusOwner,
                                                    FocusEvent.FOCUS_LOST,
                                                    fe.isTemporary(),
-                                                   newFocusOwner, cause));
+                                                   newFocusOwner, fe.getCause()));
                     // Failed to dispatch, clear by ourselves
                     if (!isEventDispatched) {
                         setGlobalFocusOwner(null);
                         if (!fe.isTemporary()) {
                             setGlobalPermanentFocusOwner(null);

@@ -550,11 +547,11 @@
 
                 if (!(newFocusOwner.isFocusable() && newFocusOwner.isShowing() &&
                     // Refuse focus on a disabled component if the focus event
                     // isn't of UNKNOWN reason (i.e. not a result of a direct request
                     // but traversal, activation or system generated).
-                    (newFocusOwner.isEnabled() || cause.equals(CausedFocusEvent.Cause.UNKNOWN))))
+                    (newFocusOwner.isEnabled() || fe.getCause().equals(FocusEvent.Cause.UNKNOWN))))
                 {
                     // we should not accept focus on such component, so reject it.
                     dequeueKeyEvents(-1, newFocusOwner);
                     if (KeyboardFocusManager.isAutoFocusTransferEnabled()) {
                         // If FOCUS_GAINED is for a disposed component (however

@@ -599,14 +596,14 @@
                 setNativeFocusOwner(getHeavyweight(newFocusOwner));
 
                 Component realOppositeComponent = this.realOppositeComponentWR.get();
                 if (realOppositeComponent != null &&
                     realOppositeComponent != fe.getOppositeComponent()) {
-                    fe = new CausedFocusEvent(newFocusOwner,
+                    fe = new FocusEvent(newFocusOwner,
                                         FocusEvent.FOCUS_GAINED,
                                         fe.isTemporary(),
-                                        realOppositeComponent, cause);
+                                        realOppositeComponent, fe.getCause());
                     ((AWTEvent) fe).isPosted = true;
                 }
                 return typeAheadAssertions(newFocusOwner, fe);
             }
 

@@ -727,14 +724,14 @@
                     }
                     if (oppositeComp == null) {
                         oppositeComp = oppositeWindow;
                     }
                     sendMessage(currentFocusOwner,
-                                new CausedFocusEvent(currentFocusOwner,
+                                new FocusEvent(currentFocusOwner,
                                                FocusEvent.FOCUS_LOST,
                                                true,
-                                               oppositeComp, CausedFocusEvent.Cause.ACTIVATION));
+                                               oppositeComp, FocusEvent.Cause.ACTIVATION));
                 }
 
                 setGlobalFocusedWindow(null);
                 if (getGlobalFocusedWindow() != null) {
                     // Focus change was rejected. Unlikely, but possible.
< prev index next >