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