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

Print this page




 293             }
 294         }
 295         return false;
 296     }
 297 
 298     /**
 299      * This method is called by the AWT event dispatcher requesting that the
 300      * current KeyboardFocusManager dispatch the specified event on its behalf.
 301      * DefaultKeyboardFocusManagers dispatch all FocusEvents, all WindowEvents
 302      * related to focus, and all KeyEvents. These events are dispatched based
 303      * on the KeyboardFocusManager's notion of the focus owner and the focused
 304      * and active Windows, sometimes overriding the source of the specified
 305      * AWTEvent. If this method returns <code>false</code>, then the AWT event
 306      * dispatcher will attempt to dispatch the event itself.
 307      *
 308      * @param e the AWTEvent to be dispatched
 309      * @return <code>true</code> if this method dispatched the event;
 310      *         <code>false</code> otherwise
 311      */
 312     public boolean dispatchEvent(AWTEvent e) {
 313         if (focusLog.isLoggable(PlatformLogger.FINE) && (e instanceof WindowEvent || e instanceof FocusEvent)) focusLog.fine("" + e);


 314         switch (e.getID()) {
 315             case WindowEvent.WINDOW_GAINED_FOCUS: {
 316                 if (repostIfFollowsKeyEvents((WindowEvent)e)) {
 317                     break;
 318                 }
 319 
 320                 WindowEvent we = (WindowEvent)e;
 321                 Window oldFocusedWindow = getGlobalFocusedWindow();
 322                 Window newFocusedWindow = we.getWindow();
 323                 if (newFocusedWindow == oldFocusedWindow) {
 324                     break;
 325                 }
 326 
 327                 if (!(newFocusedWindow.isFocusableWindow()
 328                       && newFocusedWindow.isVisible()
 329                       && newFocusedWindow.isDisplayable()))
 330                 {
 331                     // we can not accept focus on such window, so reject it.
 332                     restoreFocus(we);
 333                     break;




 293             }
 294         }
 295         return false;
 296     }
 297 
 298     /**
 299      * This method is called by the AWT event dispatcher requesting that the
 300      * current KeyboardFocusManager dispatch the specified event on its behalf.
 301      * DefaultKeyboardFocusManagers dispatch all FocusEvents, all WindowEvents
 302      * related to focus, and all KeyEvents. These events are dispatched based
 303      * on the KeyboardFocusManager's notion of the focus owner and the focused
 304      * and active Windows, sometimes overriding the source of the specified
 305      * AWTEvent. If this method returns <code>false</code>, then the AWT event
 306      * dispatcher will attempt to dispatch the event itself.
 307      *
 308      * @param e the AWTEvent to be dispatched
 309      * @return <code>true</code> if this method dispatched the event;
 310      *         <code>false</code> otherwise
 311      */
 312     public boolean dispatchEvent(AWTEvent e) {
 313         if (focusLog.isLoggable(PlatformLogger.FINE) && (e instanceof WindowEvent || e instanceof FocusEvent)) {
 314             focusLog.fine("" + e);
 315         }
 316         switch (e.getID()) {
 317             case WindowEvent.WINDOW_GAINED_FOCUS: {
 318                 if (repostIfFollowsKeyEvents((WindowEvent)e)) {
 319                     break;
 320                 }
 321 
 322                 WindowEvent we = (WindowEvent)e;
 323                 Window oldFocusedWindow = getGlobalFocusedWindow();
 324                 Window newFocusedWindow = we.getWindow();
 325                 if (newFocusedWindow == oldFocusedWindow) {
 326                     break;
 327                 }
 328 
 329                 if (!(newFocusedWindow.isFocusableWindow()
 330                       && newFocusedWindow.isVisible()
 331                       && newFocusedWindow.isDisplayable()))
 332                 {
 333                     // we can not accept focus on such window, so reject it.
 334                     restoreFocus(we);
 335                     break;