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

Print this page




 209      * {@code icons} is the graphical way we can
 210      * represent the frames and dialogs.
 211      * {@code Window} can't display icon but it's
 212      * being inherited by owned {@code Dialog}s.
 213      *
 214      * @serial
 215      * @see #getIconImages
 216      * @see #setIconImages(List<? extends Image>)
 217      */
 218     transient java.util.List<Image> icons;
 219 
 220     /**
 221      * Holds the reference to the component which last had focus in this window
 222      * before it lost focus.
 223      */
 224     private transient Component temporaryLostComponent;
 225 
 226     static boolean systemSyncLWRequests = false;
 227     boolean     syncLWRequests = false;
 228     transient boolean beforeFirstShow = true;

 229 
 230     static final int OPENED = 0x01;
 231 
 232     /**
 233      * An Integer value representing the Window State.
 234      *
 235      * @serial
 236      * @since 1.2
 237      * @see #show
 238      */
 239     int state;
 240 
 241     /**
 242      * A boolean value representing Window always-on-top state
 243      * @since 1.5
 244      * @serial
 245      * @see #setAlwaysOnTop
 246      * @see #isAlwaysOnTop
 247      */
 248     private boolean alwaysOnTop;


1145     public void dispose() {
1146         doDispose();
1147     }
1148 
1149     /*
1150      * Fix for 4872170.
1151      * If dispose() is called on parent then its children have to be disposed as well
1152      * as reported in javadoc. So we need to implement this functionality even if a
1153      * child overrides dispose() in a wrong way without calling super.dispose().
1154      */
1155     void disposeImpl() {
1156         dispose();
1157         if (getPeer() != null) {
1158             doDispose();
1159         }
1160     }
1161 
1162     void doDispose() {
1163     class DisposeAction implements Runnable {
1164         public void run() {


1165             // Check if this window is the fullscreen window for the
1166             // device. Exit the fullscreen mode prior to disposing
1167             // of the window if that's the case.
1168             GraphicsDevice gd = getGraphicsConfiguration().getDevice();
1169             if (gd.getFullScreenWindow() == Window.this) {
1170                 gd.setFullScreenWindow(null);
1171             }
1172 
1173             Object[] ownedWindowArray;
1174             synchronized(ownedWindowList) {
1175                 ownedWindowArray = new Object[ownedWindowList.size()];
1176                 ownedWindowList.copyInto(ownedWindowArray);
1177             }
1178             for (int i = 0; i < ownedWindowArray.length; i++) {
1179                 Window child = (Window) (((WeakReference)
1180                                (ownedWindowArray[i])).get());
1181                 if (child != null) {
1182                     child.disposeImpl();
1183                 }
1184             }
1185             hide();
1186             beforeFirstShow = true;
1187             removeNotify();
1188             synchronized (inputContextLock) {
1189                 if (inputContext != null) {
1190                     inputContext.dispose();
1191                     inputContext = null;
1192                 }
1193             }
1194             clearCurrentFocusCycleRootOnHide();



1195         }
1196     }
1197         DisposeAction action = new DisposeAction();
1198         if (EventQueue.isDispatchThread()) {
1199             action.run();
1200         }
1201         else {
1202             try {
1203                 EventQueue.invokeAndWait(action);
1204             }
1205             catch (InterruptedException e) {
1206                 System.err.println("Disposal was interrupted:");
1207                 e.printStackTrace();
1208             }
1209             catch (InvocationTargetException e) {
1210                 System.err.println("Exception during disposal:");
1211                 e.printStackTrace();
1212             }
1213         }
1214         // Execute outside the Runnable because postWindowEvent is


2715 
2716     /**
2717      * @deprecated As of JDK version 1.1
2718      * replaced by <code>dispatchEvent(AWTEvent)</code>.
2719      */
2720     @Deprecated
2721     public boolean postEvent(Event e) {
2722         if (handleEvent(e)) {
2723             e.consume();
2724             return true;
2725         }
2726         return false;
2727     }
2728 
2729     /**
2730      * Checks if this Window is showing on screen.
2731      * @see Component#setVisible
2732     */
2733     public boolean isShowing() {
2734         return visible;




2735     }
2736 
2737     /**
2738      * @deprecated As of J2SE 1.4, replaced by
2739      * {@link Component#applyComponentOrientation Component.applyComponentOrientation}.
2740      */
2741     @Deprecated
2742     public void applyResourceBundle(ResourceBundle rb) {
2743         applyComponentOrientation(ComponentOrientation.getOrientation(rb));
2744     }
2745 
2746     /**
2747      * @deprecated As of J2SE 1.4, replaced by
2748      * {@link Component#applyComponentOrientation Component.applyComponentOrientation}.
2749      */
2750     @Deprecated
2751     public void applyResourceBundle(String rbName) {
2752         applyResourceBundle(ResourceBundle.getBundle(rbName));
2753     }
2754 




 209      * {@code icons} is the graphical way we can
 210      * represent the frames and dialogs.
 211      * {@code Window} can't display icon but it's
 212      * being inherited by owned {@code Dialog}s.
 213      *
 214      * @serial
 215      * @see #getIconImages
 216      * @see #setIconImages(List<? extends Image>)
 217      */
 218     transient java.util.List<Image> icons;
 219 
 220     /**
 221      * Holds the reference to the component which last had focus in this window
 222      * before it lost focus.
 223      */
 224     private transient Component temporaryLostComponent;
 225 
 226     static boolean systemSyncLWRequests = false;
 227     boolean     syncLWRequests = false;
 228     transient boolean beforeFirstShow = true;
 229     private transient boolean disposing = false;
 230     
 231     static final int OPENED = 0x01;
 232 
 233     /**
 234      * An Integer value representing the Window State.
 235      *
 236      * @serial
 237      * @since 1.2
 238      * @see #show
 239      */
 240     int state;
 241 
 242     /**
 243      * A boolean value representing Window always-on-top state
 244      * @since 1.5
 245      * @serial
 246      * @see #setAlwaysOnTop
 247      * @see #isAlwaysOnTop
 248      */
 249     private boolean alwaysOnTop;


1146     public void dispose() {
1147         doDispose();
1148     }
1149 
1150     /*
1151      * Fix for 4872170.
1152      * If dispose() is called on parent then its children have to be disposed as well
1153      * as reported in javadoc. So we need to implement this functionality even if a
1154      * child overrides dispose() in a wrong way without calling super.dispose().
1155      */
1156     void disposeImpl() {
1157         dispose();
1158         if (getPeer() != null) {
1159             doDispose();
1160         }
1161     }
1162 
1163     void doDispose() {
1164     class DisposeAction implements Runnable {
1165         public void run() {
1166             disposing = true;
1167             try {
1168                 // Check if this window is the fullscreen window for the
1169                 // device. Exit the fullscreen mode prior to disposing
1170                 // of the window if that's the case.
1171                 GraphicsDevice gd = getGraphicsConfiguration().getDevice();
1172                 if (gd.getFullScreenWindow() == Window.this) {
1173                     gd.setFullScreenWindow(null);
1174                 }
1175 
1176                 Object[] ownedWindowArray;
1177                 synchronized(ownedWindowList) {
1178                     ownedWindowArray = new Object[ownedWindowList.size()];
1179                     ownedWindowList.copyInto(ownedWindowArray);
1180                 }
1181                 for (int i = 0; i < ownedWindowArray.length; i++) {
1182                     Window child = (Window) (((WeakReference)
1183                                    (ownedWindowArray[i])).get());
1184                     if (child != null) {
1185                         child.disposeImpl();
1186                     }
1187                 }
1188                 hide();
1189                 beforeFirstShow = true;
1190                 removeNotify();
1191                 synchronized (inputContextLock) {
1192                     if (inputContext != null) {
1193                         inputContext.dispose();
1194                         inputContext = null;
1195                     }
1196                 }
1197                 clearCurrentFocusCycleRootOnHide();
1198             } finally {
1199                 disposing = false;
1200             }
1201         }
1202     }
1203         DisposeAction action = new DisposeAction();
1204         if (EventQueue.isDispatchThread()) {
1205             action.run();
1206         }
1207         else {
1208             try {
1209                 EventQueue.invokeAndWait(action);
1210             }
1211             catch (InterruptedException e) {
1212                 System.err.println("Disposal was interrupted:");
1213                 e.printStackTrace();
1214             }
1215             catch (InvocationTargetException e) {
1216                 System.err.println("Exception during disposal:");
1217                 e.printStackTrace();
1218             }
1219         }
1220         // Execute outside the Runnable because postWindowEvent is


2721 
2722     /**
2723      * @deprecated As of JDK version 1.1
2724      * replaced by <code>dispatchEvent(AWTEvent)</code>.
2725      */
2726     @Deprecated
2727     public boolean postEvent(Event e) {
2728         if (handleEvent(e)) {
2729             e.consume();
2730             return true;
2731         }
2732         return false;
2733     }
2734 
2735     /**
2736      * Checks if this Window is showing on screen.
2737      * @see Component#setVisible
2738     */
2739     public boolean isShowing() {
2740         return visible;
2741     }
2742 
2743     boolean isDisposing() {
2744         return disposing;
2745     }
2746 
2747     /**
2748      * @deprecated As of J2SE 1.4, replaced by
2749      * {@link Component#applyComponentOrientation Component.applyComponentOrientation}.
2750      */
2751     @Deprecated
2752     public void applyResourceBundle(ResourceBundle rb) {
2753         applyComponentOrientation(ComponentOrientation.getOrientation(rb));
2754     }
2755 
2756     /**
2757      * @deprecated As of J2SE 1.4, replaced by
2758      * {@link Component#applyComponentOrientation Component.applyComponentOrientation}.
2759      */
2760     @Deprecated
2761     public void applyResourceBundle(String rbName) {
2762         applyResourceBundle(ResourceBundle.getBundle(rbName));
2763     }
2764