35 import java.io.IOException;
36 import java.io.ObjectInputStream;
37 import java.io.ObjectOutputStream;
38 import java.io.OptionalDataException;
39 import java.io.Serializable;
40 import java.lang.ref.WeakReference;
41 import java.lang.reflect.InvocationTargetException;
42 import java.security.AccessController;
43 import java.util.ArrayList;
44 import java.util.Arrays;
45 import java.util.EventListener;
46 import java.util.Locale;
47 import java.util.ResourceBundle;
48 import java.util.Set;
49 import java.util.Vector;
50 import java.util.concurrent.atomic.AtomicBoolean;
51 import javax.accessibility.*;
52 import sun.awt.AWTAccessor;
53 import sun.awt.AWTPermissions;
54 import sun.awt.AppContext;
55 import sun.awt.CausedFocusEvent;
56 import sun.awt.DebugSettings;
57 import sun.awt.SunToolkit;
58 import sun.awt.util.IdentityArrayList;
59 import sun.java2d.pipe.Region;
60 import sun.security.action.GetPropertyAction;
61 import sun.util.logging.PlatformLogger;
62
63 /**
64 * A {@code Window} object is a top-level window with no borders and no
65 * menubar.
66 * The default layout for a window is {@code BorderLayout}.
67 * <p>
68 * A window must have either a frame, dialog, or another window defined as its
69 * owner when it's constructed.
70 * <p>
71 * In a multi-screen environment, you can create a {@code Window}
72 * on a different screen device by constructing the {@code Window}
73 * with {@link #Window(Window, GraphicsConfiguration)}. The
74 * {@code GraphicsConfiguration} object is one of the
75 * {@code GraphicsConfiguration} objects of the target screen device.
2586 */
2587 public void setFocusableWindowState(boolean focusableWindowState) {
2588 boolean oldFocusableWindowState;
2589 synchronized (this) {
2590 oldFocusableWindowState = this.focusableWindowState;
2591 this.focusableWindowState = focusableWindowState;
2592 }
2593 WindowPeer peer = (WindowPeer)this.peer;
2594 if (peer != null) {
2595 peer.updateFocusableWindowState();
2596 }
2597 firePropertyChange("focusableWindowState", oldFocusableWindowState,
2598 focusableWindowState);
2599 if (oldFocusableWindowState && !focusableWindowState && isFocused()) {
2600 for (Window owner = getOwner();
2601 owner != null;
2602 owner = owner.getOwner())
2603 {
2604 Component toFocus =
2605 KeyboardFocusManager.getMostRecentFocusOwner(owner);
2606 if (toFocus != null && toFocus.requestFocus(false, CausedFocusEvent.Cause.ACTIVATION)) {
2607 return;
2608 }
2609 }
2610 KeyboardFocusManager.getCurrentKeyboardFocusManager().
2611 clearGlobalFocusOwnerPriv();
2612 }
2613 }
2614
2615 /**
2616 * Sets whether this window should receive focus on
2617 * subsequently being shown (with a call to {@link #setVisible setVisible(true)}),
2618 * or being moved to the front (with a call to {@link #toFront}).
2619 * <p>
2620 * Note that {@link #setVisible setVisible(true)} may be called indirectly
2621 * (e.g. when showing an owner of the window makes the window to be shown).
2622 * {@link #toFront} may also be called indirectly (e.g. when
2623 * {@link #setVisible setVisible(true)} is called on already visible window).
2624 * In all such cases this property takes effect as well.
2625 * <p>
2626 * The value of the property is not inherited by owned windows.
|
35 import java.io.IOException;
36 import java.io.ObjectInputStream;
37 import java.io.ObjectOutputStream;
38 import java.io.OptionalDataException;
39 import java.io.Serializable;
40 import java.lang.ref.WeakReference;
41 import java.lang.reflect.InvocationTargetException;
42 import java.security.AccessController;
43 import java.util.ArrayList;
44 import java.util.Arrays;
45 import java.util.EventListener;
46 import java.util.Locale;
47 import java.util.ResourceBundle;
48 import java.util.Set;
49 import java.util.Vector;
50 import java.util.concurrent.atomic.AtomicBoolean;
51 import javax.accessibility.*;
52 import sun.awt.AWTAccessor;
53 import sun.awt.AWTPermissions;
54 import sun.awt.AppContext;
55 import sun.awt.DebugSettings;
56 import sun.awt.SunToolkit;
57 import sun.awt.util.IdentityArrayList;
58 import sun.java2d.pipe.Region;
59 import sun.security.action.GetPropertyAction;
60 import sun.util.logging.PlatformLogger;
61
62 /**
63 * A {@code Window} object is a top-level window with no borders and no
64 * menubar.
65 * The default layout for a window is {@code BorderLayout}.
66 * <p>
67 * A window must have either a frame, dialog, or another window defined as its
68 * owner when it's constructed.
69 * <p>
70 * In a multi-screen environment, you can create a {@code Window}
71 * on a different screen device by constructing the {@code Window}
72 * with {@link #Window(Window, GraphicsConfiguration)}. The
73 * {@code GraphicsConfiguration} object is one of the
74 * {@code GraphicsConfiguration} objects of the target screen device.
2585 */
2586 public void setFocusableWindowState(boolean focusableWindowState) {
2587 boolean oldFocusableWindowState;
2588 synchronized (this) {
2589 oldFocusableWindowState = this.focusableWindowState;
2590 this.focusableWindowState = focusableWindowState;
2591 }
2592 WindowPeer peer = (WindowPeer)this.peer;
2593 if (peer != null) {
2594 peer.updateFocusableWindowState();
2595 }
2596 firePropertyChange("focusableWindowState", oldFocusableWindowState,
2597 focusableWindowState);
2598 if (oldFocusableWindowState && !focusableWindowState && isFocused()) {
2599 for (Window owner = getOwner();
2600 owner != null;
2601 owner = owner.getOwner())
2602 {
2603 Component toFocus =
2604 KeyboardFocusManager.getMostRecentFocusOwner(owner);
2605 if (toFocus != null && toFocus.requestFocus(false, FocusEvent.Cause.ACTIVATION)) {
2606 return;
2607 }
2608 }
2609 KeyboardFocusManager.getCurrentKeyboardFocusManager().
2610 clearGlobalFocusOwnerPriv();
2611 }
2612 }
2613
2614 /**
2615 * Sets whether this window should receive focus on
2616 * subsequently being shown (with a call to {@link #setVisible setVisible(true)}),
2617 * or being moved to the front (with a call to {@link #toFront}).
2618 * <p>
2619 * Note that {@link #setVisible setVisible(true)} may be called indirectly
2620 * (e.g. when showing an owner of the window makes the window to be shown).
2621 * {@link #toFront} may also be called indirectly (e.g. when
2622 * {@link #setVisible setVisible(true)} is called on already visible window).
2623 * In all such cases this property takes effect as well.
2624 * <p>
2625 * The value of the property is not inherited by owned windows.
|