< prev index next >

src/java.desktop/share/classes/java/awt/Window.java

Print this page




  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.


2582      */
2583     public void setFocusableWindowState(boolean focusableWindowState) {
2584         boolean oldFocusableWindowState;
2585         synchronized (this) {
2586             oldFocusableWindowState = this.focusableWindowState;
2587             this.focusableWindowState = focusableWindowState;
2588         }
2589         WindowPeer peer = (WindowPeer)this.peer;
2590         if (peer != null) {
2591             peer.updateFocusableWindowState();
2592         }
2593         firePropertyChange("focusableWindowState", oldFocusableWindowState,
2594                            focusableWindowState);
2595         if (oldFocusableWindowState && !focusableWindowState && isFocused()) {
2596             for (Window owner = getOwner();
2597                  owner != null;
2598                  owner = owner.getOwner())
2599                 {
2600                     Component toFocus =
2601                         KeyboardFocusManager.getMostRecentFocusOwner(owner);
2602                     if (toFocus != null && toFocus.requestFocus(false, CausedFocusEvent.Cause.ACTIVATION)) {
2603                         return;
2604                     }
2605                 }
2606             KeyboardFocusManager.getCurrentKeyboardFocusManager().
2607                 clearGlobalFocusOwnerPriv();
2608         }
2609     }
2610 
2611     /**
2612      * Sets whether this window should receive focus on
2613      * subsequently being shown (with a call to {@link #setVisible setVisible(true)}),
2614      * or being moved to the front (with a call to {@link #toFront}).
2615      * <p>
2616      * Note that {@link #setVisible setVisible(true)} may be called indirectly
2617      * (e.g. when showing an owner of the window makes the window to be shown).
2618      * {@link #toFront} may also be called indirectly (e.g. when
2619      * {@link #setVisible setVisible(true)} is called on already visible window).
2620      * In all such cases this property takes effect as well.
2621      * <p>
2622      * 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.


2581      */
2582     public void setFocusableWindowState(boolean focusableWindowState) {
2583         boolean oldFocusableWindowState;
2584         synchronized (this) {
2585             oldFocusableWindowState = this.focusableWindowState;
2586             this.focusableWindowState = focusableWindowState;
2587         }
2588         WindowPeer peer = (WindowPeer)this.peer;
2589         if (peer != null) {
2590             peer.updateFocusableWindowState();
2591         }
2592         firePropertyChange("focusableWindowState", oldFocusableWindowState,
2593                            focusableWindowState);
2594         if (oldFocusableWindowState && !focusableWindowState && isFocused()) {
2595             for (Window owner = getOwner();
2596                  owner != null;
2597                  owner = owner.getOwner())
2598                 {
2599                     Component toFocus =
2600                         KeyboardFocusManager.getMostRecentFocusOwner(owner);
2601                     if (toFocus != null && toFocus.requestFocus(false, FocusEvent.Cause.ACTIVATION)) {
2602                         return;
2603                     }
2604                 }
2605             KeyboardFocusManager.getCurrentKeyboardFocusManager().
2606                 clearGlobalFocusOwnerPriv();
2607         }
2608     }
2609 
2610     /**
2611      * Sets whether this window should receive focus on
2612      * subsequently being shown (with a call to {@link #setVisible setVisible(true)}),
2613      * or being moved to the front (with a call to {@link #toFront}).
2614      * <p>
2615      * Note that {@link #setVisible setVisible(true)} may be called indirectly
2616      * (e.g. when showing an owner of the window makes the window to be shown).
2617      * {@link #toFront} may also be called indirectly (e.g. when
2618      * {@link #setVisible setVisible(true)} is called on already visible window).
2619      * In all such cases this property takes effect as well.
2620      * <p>
2621      * The value of the property is not inherited by owned windows.


< prev index next >