1 /* Frame.java -- AWT toplevel window
2 Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
41 import java.awt.peer.FramePeer;
42 import java.awt.peer.WindowPeer;
43 import java.awt.peer.ContainerPeer;
44 import java.awt.peer.ComponentPeer;
45 import java.io.Serializable;
46 import java.util.Enumeration;
47 import java.util.Vector;
50 * This class is a top-level window with a title bar and window
53 * @author Aaron M. Renn (arenn@urbanophile.com)
55 public class Frame extends Window implements MenuContainer, Serializable
63 * Constant for a cross-hair cursor.
64 * @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
66 public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
69 * Constant for a cursor over a text field.
70 * @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
72 public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
75 * Constant for a cursor to display while waiting for an action to complete.
76 * @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
78 public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
81 * Cursor used over SW corner of window decorations.
82 * @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
84 public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
87 * Cursor used over SE corner of window decorations.
88 * @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
90 public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
93 * Cursor used over NW corner of window decorations.
94 * @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
96 public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
99 * Cursor used over NE corner of window decorations.
100 * @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
102 public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
105 * Cursor used over N edge of window decorations.
106 * @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
108 public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
111 * Cursor used over S edge of window decorations.
112 * @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
114 public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
117 * Cursor used over E edge of window decorations.
118 * @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
120 public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
123 * Cursor used over W edge of window decorations.
124 * @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
126 public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
129 * Constant for a hand cursor.
130 * @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
132 public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
135 * Constant for a cursor used during window move operations.
136 * @deprecated Use <code>Cursor.MOVE_CURSOR</code> instead.
138 public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
140 // Serialization version constant
141 private static final long serialVersionUID = 2673458971256075116L;
143 /*************************************************************************/
150 * @serial The version of the class data being serialized
151 * // FIXME: what is this value?
153 private int frameSerializedDataVersion;
156 * @serial Image used as the icon when this frame is minimized.
161 * @serial Constant used by the JDK Motif peer set. Not used in
162 * this implementation.
164 private boolean mbManagement;
167 * @serial The menu bar for this frame.
169 //private MenuBar menuBar = new MenuBar();
170 private MenuBar menuBar;
173 * @serial A list of other top-level windows owned by this window.
175 Vector ownedWindows = new Vector();
178 * @serial Indicates whether or not this frame is resizable.
180 private boolean resizable = true;
183 * @serial The state of this frame.
184 * // FIXME: What are the values here?
189 * @serial The title of the frame.
191 private String title = "";
193 /*************************************************************************/
200 * Initializes a new instance of <code>Frame</code> that is not visible
209 /*************************************************************************/
212 * Initializes a new instance of <code>Frame</code> that is not visible
213 * and has the specified title.
215 * @param title The title of this frame.
221 System.err.println("returned");
223 System.err.println("end");
227 Frame(GraphicsConfiguration gc)
233 Frame(String title, GraphicsConfiguration gc)
239 /*************************************************************************/
246 * Returns this frame's title string.
248 * @return This frame's title string.
256 /*************************************************************************/
259 * Sets this frame's title to the specified value.
261 * @param title The new frame title.
263 public synchronized void
264 setTitle(String title)
268 ((FramePeer) peer).setTitle(title);
271 /*************************************************************************/
274 * Returns this frame's icon.
276 * @return This frame's icon, or <code>null</code> if this frame does not
285 /*************************************************************************/
288 * Sets this frame's icon to the specified value.
290 * @icon The new icon for this frame.
292 public synchronized void
293 setIconImage(Image icon)
297 ((FramePeer) peer).setIconImage(icon);
300 /*************************************************************************/
303 * Returns this frame's menu bar.
305 * @return This frame's menu bar, or <code>null</code> if this frame
306 * does not have a menu bar.
314 /*************************************************************************/
317 * Sets this frame's menu bar.
319 * @param menuBar The new menu bar for this frame.
321 public synchronized void
322 setMenuBar(MenuBar menuBar)
324 this.menuBar = menuBar;
326 ((FramePeer) peer).setMenuBar(menuBar);
329 /*************************************************************************/
332 * Tests whether or not this frame is resizable. This will be
333 * <code>true</code> by default.
335 * @return <code>true</code> if this frame is resizable, <code>false</code>
344 /*************************************************************************/
347 * Sets the resizability of this frame to the specified value.
349 * @param resizable <code>true</code> to make the frame resizable,
350 * <code>false</code> to make it non-resizable.
352 public synchronized void
353 setResizable(boolean resizable)
355 this.resizable = resizable;
357 ((FramePeer) peer).setResizable(resizable);
360 /*************************************************************************/
363 * Returns the cursor type of the cursor for this window. This will
364 * be one of the constants in this class.
366 * @return The cursor type for this frame.
368 * @deprecated Use <code>Component.getCursor()</code> instead.
373 return(getCursor().getType());
376 /*************************************************************************/
379 * Sets the cursor for this window to the specified type. The specified
380 * type should be one of the constants in this class.
382 * @param type The cursor type.
384 * @deprecated. Use <code>Component.setCursor(Cursor)</code> instead.
389 setCursor(new Cursor(type));
392 /*************************************************************************/
395 * Removes the specified component from this frame's menu.
397 * @param menu The menu component to remove.
400 remove(MenuComponent menu)
402 menuBar.remove(menu);
405 /*************************************************************************/
408 * Notifies this frame that it should create its native peer.
414 peer = getToolkit ().createFrame (this);
418 /*************************************************************************/
421 * Destroys any resources associated with this frame. This includes
422 * all components in the frame and all owned toplevel windows.
427 Enumeration e = ownedWindows.elements();
428 while(e.hasMoreElements())
430 Window w = (Window)e.nextElement();
437 /*************************************************************************/
440 * Returns a debugging string describing this window.
442 * @return A debugging string describing this window.
447 return(getClass().getName());
453 /* FIXME: State might have changed in the peer... Must check. */
458 public static Frame[]
461 //Frame[] array = new Frames[frames.size()];
462 //return frames.toArray(array);
464 // see finalize() comment
465 String msg = "FIXME: can't be implemented without weak references";
466 throw new UnsupportedOperationException(msg);