/[classpath]/classpath/java/awt/DefaultKeyboardFocusManager.java
ViewVC logotype

Diff of /classpath/java/awt/DefaultKeyboardFocusManager.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mkoch, Mon May 31 21:11:46 2004 UTC revision 1.3 by mark, Thu Jul 22 19:45:38 2004 UTC
# Line 162  public class DefaultKeyboardFocusManager Line 162  public class DefaultKeyboardFocusManager
162        {        {
163          Component target = (Component) e.getSource ();          Component target = (Component) e.getSource ();
164    
165          if (e.id == FocusEvent.FOCUS_GAINED          if (e.id == FocusEvent.FOCUS_GAINED)
             && !(target instanceof Window))  
166            {            {
167              if (((FocusEvent) e).isTemporary ())              if (((FocusEvent) e).isTemporary ())
168                setGlobalFocusOwner (target);                setGlobalFocusOwner (target);
169              else              else
170                setGlobalPermanentFocusOwner (target);                setGlobalPermanentFocusOwner (target);
171            }            }
172            else if (e.id == FocusEvent.FOCUS_LOST)
173              {
174                // We need to set the window's focus owner here; we can't
175                // set it when the window loses focus because by that time
176                // the previous focus owner has already lost focus
177                // (FOCUS_LOST events are delivered before
178                // WINDOW_LOST_FOCUS events).
179    
180                // Find the target Component's top-level ancestor.
181                Container parent = target.getParent ();
182    
183                while (parent != null
184                       && !(parent instanceof Window))
185                  parent = parent.getParent ();
186    
187                Window toplevel = parent == null ?
188                  (Window) target : (Window) parent;
189    
190                Component focusOwner = getFocusOwner ();
191                if (focusOwner != null)
192                  toplevel.setFocusOwner (focusOwner);
193    
194                if (((FocusEvent) e).isTemporary ())
195                  setGlobalFocusOwner (null);
196                else
197                  setGlobalPermanentFocusOwner (null);
198              }
199    
         if (!(target instanceof Window))  
200            target.dispatchEvent (e);            target.dispatchEvent (e);
201    
202          return true;          return true;
# Line 192  public class DefaultKeyboardFocusManager Line 217  public class DefaultKeyboardFocusManager
217          // processKeyEvent checks if this event represents a focus          // processKeyEvent checks if this event represents a focus
218          // traversal key stroke.          // traversal key stroke.
219          Component focusOwner = getGlobalPermanentFocusOwner ();          Component focusOwner = getGlobalPermanentFocusOwner ();
220    
221            if (focusOwner != null)
222          processKeyEvent (focusOwner, (KeyEvent) e);          processKeyEvent (focusOwner, (KeyEvent) e);
223    
224          if (e.isConsumed ())          if (e.isConsumed ())
# Line 230  public class DefaultKeyboardFocusManager Line 257  public class DefaultKeyboardFocusManager
257    {    {
258      Component focusOwner = getGlobalPermanentFocusOwner ();      Component focusOwner = getGlobalPermanentFocusOwner ();
259    
260        if (focusOwner != null)
261      focusOwner.dispatchEvent (e);      focusOwner.dispatchEvent (e);
262    
263      // Loop through all registered KeyEventPostProcessors, giving      // Loop through all registered KeyEventPostProcessors, giving

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26