src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java

Print this page




  36 import java.awt.peer.KeyboardFocusManagerPeer;
  37 import java.awt.peer.ComponentPeer;
  38 
  39 import java.lang.reflect.InvocationTargetException;
  40 import java.lang.reflect.Method;
  41 
  42 import sun.util.logging.PlatformLogger;
  43 
  44 public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManagerPeer {
  45 
  46     private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.focus.KeyboardFocusManagerPeerImpl");
  47 
  48     private static AWTAccessor.KeyboardFocusManagerAccessor kfmAccessor =
  49         AWTAccessor.getKeyboardFocusManagerAccessor();
  50 
  51     // The constants are copied from java.awt.KeyboardFocusManager
  52     public static final int SNFH_FAILURE         = 0;
  53     public static final int SNFH_SUCCESS_HANDLED = 1;
  54     public static final int SNFH_SUCCESS_PROCEED = 2;
  55 
  56     protected KeyboardFocusManager manager;
  57 
  58     public KeyboardFocusManagerPeerImpl(KeyboardFocusManager manager) {
  59         this.manager = manager;
  60     }
  61 
  62     @Override
  63     public void clearGlobalFocusOwner(Window activeWindow) {
  64         if (activeWindow != null) {
  65             Component focusOwner = activeWindow.getFocusOwner();
  66             if (focusLog.isLoggable(PlatformLogger.FINE))
  67                 focusLog.fine("Clearing global focus owner " + focusOwner);
  68             if (focusOwner != null) {
  69                 FocusEvent fl = new CausedFocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
  70                                                      CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
  71                 SunToolkit.postPriorityEvent(fl);
  72             }
  73         }
  74     }
  75 
  76     /*
  77      * WARNING: Don't call it on the Toolkit thread.
  78      *
  79      * Checks if the component:
  80      * 1) accepts focus on click (in general)
  81      * 2) may be a focus owner (in particular)




  36 import java.awt.peer.KeyboardFocusManagerPeer;
  37 import java.awt.peer.ComponentPeer;
  38 
  39 import java.lang.reflect.InvocationTargetException;
  40 import java.lang.reflect.Method;
  41 
  42 import sun.util.logging.PlatformLogger;
  43 
  44 public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManagerPeer {
  45 
  46     private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.focus.KeyboardFocusManagerPeerImpl");
  47 
  48     private static AWTAccessor.KeyboardFocusManagerAccessor kfmAccessor =
  49         AWTAccessor.getKeyboardFocusManagerAccessor();
  50 
  51     // The constants are copied from java.awt.KeyboardFocusManager
  52     public static final int SNFH_FAILURE         = 0;
  53     public static final int SNFH_SUCCESS_HANDLED = 1;
  54     public static final int SNFH_SUCCESS_PROCEED = 2;
  55 






  56     @Override
  57     public void clearGlobalFocusOwner(Window activeWindow) {
  58         if (activeWindow != null) {
  59             Component focusOwner = activeWindow.getFocusOwner();
  60             if (focusLog.isLoggable(PlatformLogger.FINE))
  61                 focusLog.fine("Clearing global focus owner " + focusOwner);
  62             if (focusOwner != null) {
  63                 FocusEvent fl = new CausedFocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
  64                                                      CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
  65                 SunToolkit.postPriorityEvent(fl);
  66             }
  67         }
  68     }
  69 
  70     /*
  71      * WARNING: Don't call it on the Toolkit thread.
  72      *
  73      * Checks if the component:
  74      * 1) accepts focus on click (in general)
  75      * 2) may be a focus owner (in particular)