private transient GraphicsConfiguration graphicsConfiguration;
private transient AccessibleContext accessibleContext;
+ private transient boolean shown;
+
/**
* This (package access) constructor is used by subclasses that want
* to build windows that do not have parents. Eg. toplevel
Window()
{
visible = false;
+ // Windows are the only Containers that default to being focus
+ // cycle roots.
+ focusCycleRoot = true;
setLayout(new BorderLayout());
}
validate();
super.show();
toFront();
+
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+ manager.setGlobalFocusedWindow (this);
+
+ if (!shown)
+ {
+ FocusTraversalPolicy policy = getFocusTraversalPolicy ();
+ Component initialFocusOwner = null;
+
+ if (policy != null)
+ initialFocusOwner = policy.getInitialComponent (this);
+
+ if (initialFocusOwner != null)
+ initialFocusOwner.requestFocusInWindow (false);
+
+ shown = true;
+ }
}
public void hide()
* @return The component that has focus, or <code>null</code> if no
* component has focus.
*/
- public Component getFocusOwner()
+ public Component getFocusOwner ()
{
- // FIXME
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+
+ Window activeWindow = manager.getActiveWindow ();
+
+ // The currently-focused Component belongs to the active Window.
+ if (activeWindow == this)
+ return manager.getFocusOwner ();
+
return null;
}