187 |
|
|
188 |
// Keep track of this window's focus owner. |
// Keep track of this window's focus owner. |
189 |
|
|
190 |
// Find the target Component's top-level ancestor. |
// Find the target Component's top-level ancestor. target |
191 |
|
// may be a window. |
192 |
Container parent = target.getParent (); |
Container parent = target.getParent (); |
193 |
|
|
194 |
while (parent != null |
while (parent != null |
195 |
&& !(parent instanceof Window)) |
&& !(parent instanceof Window)) |
196 |
parent = parent.getParent (); |
parent = parent.getParent (); |
197 |
|
|
198 |
Window toplevel = parent == null ? |
// If the parent is null and target is not a window, then target is an |
199 |
(Window) target : (Window) parent; |
// unanchored component and so we don't want to set the focus owner. |
200 |
|
if (! (parent == null && ! (target instanceof Window))) |
201 |
|
{ |
202 |
|
Window toplevel = parent == null ? |
203 |
|
(Window) target : (Window) parent; |
204 |
|
|
205 |
Component focusOwner = getFocusOwner (); |
Component focusOwner = getFocusOwner (); |
206 |
if (focusOwner != null |
if (focusOwner != null |
207 |
&& ! (focusOwner instanceof Window)) |
&& ! (focusOwner instanceof Window)) |
208 |
toplevel.setFocusOwner (focusOwner); |
toplevel.setFocusOwner (focusOwner); |
209 |
|
} |
210 |
} |
} |
211 |
else if (e.id == FocusEvent.FOCUS_LOST) |
else if (e.id == FocusEvent.FOCUS_LOST) |
212 |
{ |
{ |