src/share/classes/java/awt/Frame.java

Print this page


   1 /*
   2  * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1072             str += ",normal";
1073         }
1074         else {
1075             if ((state & ICONIFIED) != 0) {
1076                 str += ",iconified";
1077             }
1078             if ((state & MAXIMIZED_BOTH) == MAXIMIZED_BOTH) {
1079                 str += ",maximized";
1080             }
1081             else if ((state & MAXIMIZED_HORIZ) != 0) {
1082                 str += ",maximized_horiz";
1083             }
1084             else if ((state & MAXIMIZED_VERT) != 0) {
1085                 str += ",maximized_vert";
1086             }
1087         }
1088         return str;
1089     }
1090 
1091     /**



1092      * @deprecated As of JDK version 1.1,
1093      * replaced by <code>Component.setCursor(Cursor)</code>.
1094      */
1095     @Deprecated
1096     public void setCursor(int cursorType) {
1097         if (cursorType < DEFAULT_CURSOR || cursorType > MOVE_CURSOR) {
1098             throw new IllegalArgumentException("illegal cursor type");
1099         }
1100         setCursor(Cursor.getPredefinedCursor(cursorType));
1101     }
1102 
1103     /**
1104      * @deprecated As of JDK version 1.1,
1105      * replaced by <code>Component.getCursor()</code>.

1106      */
1107     @Deprecated
1108     public int getCursorType() {
1109         return (getCursor().getType());
1110     }
1111 
1112     /**
1113      * Returns an array of all {@code Frame}s created by this application.
1114      * If called from an applet, the array includes only the {@code Frame}s
1115      * accessible by that applet.
1116      * <p>
1117      * <b>Warning:</b> this method may return system created frames, such
1118      * as a shared, hidden frame which is used by Swing. Applications
1119      * should not assume the existence of these frames, nor should an
1120      * application assume anything about these frames such as component
1121      * positions, <code>LayoutManager</code>s or serialization.
1122      * <p>
1123      * <b>Note</b>: To obtain a list of all ownerless windows, including
1124      * ownerless {@code Dialog}s (introduced in release 1.6), use {@link
1125      * Window#getOwnerlessWindows Window.getOwnerlessWindows}.


1126      *
1127      * @see Window#getWindows()
1128      * @see Window#getOwnerlessWindows
1129      *
1130      * @since 1.2
1131      */
1132     public static Frame[] getFrames() {
1133         Window[] allWindows = Window.getWindows();
1134 
1135         int frameCount = 0;
1136         for (Window w : allWindows) {
1137             if (w instanceof Frame) {
1138                 frameCount++;
1139             }
1140         }
1141 
1142         Frame[] frames = new Frame[frameCount];
1143         int c = 0;
1144         for (Window w : allWindows) {
1145             if (w instanceof Frame) {


   1 /*
   2  * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1072             str += ",normal";
1073         }
1074         else {
1075             if ((state & ICONIFIED) != 0) {
1076                 str += ",iconified";
1077             }
1078             if ((state & MAXIMIZED_BOTH) == MAXIMIZED_BOTH) {
1079                 str += ",maximized";
1080             }
1081             else if ((state & MAXIMIZED_HORIZ) != 0) {
1082                 str += ",maximized_horiz";
1083             }
1084             else if ((state & MAXIMIZED_VERT) != 0) {
1085                 str += ",maximized_vert";
1086             }
1087         }
1088         return str;
1089     }
1090 
1091     /**
1092      * Sets the cursor for this frame to the specified type.
1093      *
1094      * @param  cursorType the cursor type
1095      * @deprecated As of JDK version 1.1,
1096      * replaced by <code>Component.setCursor(Cursor)</code>.
1097      */
1098     @Deprecated
1099     public void setCursor(int cursorType) {
1100         if (cursorType < DEFAULT_CURSOR || cursorType > MOVE_CURSOR) {
1101             throw new IllegalArgumentException("illegal cursor type");
1102         }
1103         setCursor(Cursor.getPredefinedCursor(cursorType));
1104     }
1105 
1106     /**
1107      * @deprecated As of JDK version 1.1,
1108      * replaced by <code>Component.getCursor()</code>.
1109      * @return the cursor type for this frame
1110      */
1111     @Deprecated
1112     public int getCursorType() {
1113         return (getCursor().getType());
1114     }
1115 
1116     /**
1117      * Returns an array of all {@code Frame}s created by this application.
1118      * If called from an applet, the array includes only the {@code Frame}s
1119      * accessible by that applet.
1120      * <p>
1121      * <b>Warning:</b> this method may return system created frames, such
1122      * as a shared, hidden frame which is used by Swing. Applications
1123      * should not assume the existence of these frames, nor should an
1124      * application assume anything about these frames such as component
1125      * positions, <code>LayoutManager</code>s or serialization.
1126      * <p>
1127      * <b>Note</b>: To obtain a list of all ownerless windows, including
1128      * ownerless {@code Dialog}s (introduced in release 1.6), use {@link
1129      * Window#getOwnerlessWindows Window.getOwnerlessWindows}.
1130      *
1131      * @return the array of all {@code Frame}s created by this application
1132      *
1133      * @see Window#getWindows()
1134      * @see Window#getOwnerlessWindows
1135      *
1136      * @since 1.2
1137      */
1138     public static Frame[] getFrames() {
1139         Window[] allWindows = Window.getWindows();
1140 
1141         int frameCount = 0;
1142         for (Window w : allWindows) {
1143             if (w instanceof Frame) {
1144                 frameCount++;
1145             }
1146         }
1147 
1148         Frame[] frames = new Frame[frameCount];
1149         int c = 0;
1150         for (Window w : allWindows) {
1151             if (w instanceof Frame) {