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 As a special exception, if you link this library with other files to
22 produce an executable, this library does not by itself cause the
23 resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License. */
30 import java.awt.peer.FramePeer;
31 import java.awt.peer.WindowPeer;
32 import java.awt.peer.ContainerPeer;
33 import java.awt.peer.ComponentPeer;
34 import java.io.Serializable;
35 import java.util.Enumeration;
36 import java.util.Vector;
39 * This class is a top-level window with a title bar and window
42 * @author Aaron M. Renn (arenn@urbanophile.com)
44 public class Frame extends Window implements MenuContainer, Serializable
52 * Constant for a cross-hair cursor.
53 * @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
55 public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
58 * Constant for a cursor over a text field.
59 * @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
61 public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
64 * Constant for a cursor to display while waiting for an action to complete.
65 * @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
67 public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
70 * Cursor used over SW corner of window decorations.
71 * @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
73 public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
76 * Cursor used over SE corner of window decorations.
77 * @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
79 public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
82 * Cursor used over NW corner of window decorations.
83 * @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
85 public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
88 * Cursor used over NE corner of window decorations.
89 * @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
91 public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
94 * Cursor used over N edge of window decorations.
95 * @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
97 public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
100 * Cursor used over S edge of window decorations.
101 * @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
103 public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
106 * Cursor used over E edge of window decorations.
107 * @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
109 public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
112 * Cursor used over W edge of window decorations.
113 * @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
115 public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
118 * Constant for a hand cursor.
119 * @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
121 public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
124 * Constant for a cursor used during window move operations.
125 * @deprecated Use <code>Cursor.MOVE_CURSOR</code> instead.
127 public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
129 // Serialization version constant
130 private static final long serialVersionUID = 2673458971256075116L;
132 /*************************************************************************/
139 * @serial The version of the class data being serialized
140 * // FIXME: what is this value?
142 private int frameSerializedDataVersion;
145 * @serial Image used as the icon when this frame is minimized.
150 * @serial Constant used by the JDK Motif peer set. Not used in
151 * this implementation.
153 private boolean mbManagement;
156 * @serial The menu bar for this frame.
158 //private MenuBar menuBar = new MenuBar();
159 private MenuBar menuBar;
162 * @serial A list of other top-level windows owned by this window.
164 Vector ownedWindows = new Vector();
167 * @serial Indicates whether or not this frame is resizable.
169 private boolean resizable = true;
172 * @serial The state of this frame.
173 * // FIXME: What are the values here?
178 * @serial The title of the frame.
180 private String title = "";
182 /*************************************************************************/
189 * Initializes a new instance of <code>Frame</code> that is not visible
198 /*************************************************************************/
201 * Initializes a new instance of <code>Frame</code> that is not visible
202 * and has the specified title.
204 * @param title The title of this frame.
210 System.err.println("returned");
212 System.err.println("end");
216 Frame(GraphicsConfiguration gc)
222 Frame(String title, GraphicsConfiguration gc)
228 /*************************************************************************/
235 * Returns this frame's title string.
237 * @return This frame's title string.
245 /*************************************************************************/
248 * Sets this frame's title to the specified value.
250 * @param title The new frame title.
252 public synchronized void
253 setTitle(String title)
257 ((FramePeer) peer).setTitle(title);
260 /*************************************************************************/
263 * Returns this frame's icon.
265 * @return This frame's icon, or <code>null</code> if this frame does not
274 /*************************************************************************/
277 * Sets this frame's icon to the specified value.
279 * @icon The new icon for this frame.
281 public synchronized void
282 setIconImage(Image icon)
286 ((FramePeer) peer).setIconImage(icon);
289 /*************************************************************************/
292 * Returns this frame's menu bar.
294 * @return This frame's menu bar, or <code>null</code> if this frame
295 * does not have a menu bar.
303 /*************************************************************************/
306 * Sets this frame's menu bar.
308 * @param menuBar The new menu bar for this frame.
310 public synchronized void
311 setMenuBar(MenuBar menuBar)
313 this.menuBar = menuBar;
315 ((FramePeer) peer).setMenuBar(menuBar);
318 /*************************************************************************/
321 * Tests whether or not this frame is resizable. This will be
322 * <code>true</code> by default.
324 * @return <code>true</code> if this frame is resizable, <code>false</code>
333 /*************************************************************************/
336 * Sets the resizability of this frame to the specified value.
338 * @param resizable <code>true</code> to make the frame resizable,
339 * <code>false</code> to make it non-resizable.
341 public synchronized void
342 setResizable(boolean resizable)
344 this.resizable = resizable;
346 ((FramePeer) peer).setResizable(resizable);
349 /*************************************************************************/
352 * Returns the cursor type of the cursor for this window. This will
353 * be one of the constants in this class.
355 * @return The cursor type for this frame.
357 * @deprecated Use <code>Component.getCursor()</code> instead.
362 return(getCursor().getType());
365 /*************************************************************************/
368 * Sets the cursor for this window to the specified type. The specified
369 * type should be one of the constants in this class.
371 * @param type The cursor type.
373 * @deprecated. Use <code>Component.setCursor(Cursor)</code> instead.
378 setCursor(new Cursor(type));
381 /*************************************************************************/
384 * Removes the specified component from this frame's menu.
386 * @param menu The menu component to remove.
389 remove(MenuComponent menu)
391 menuBar.remove(menu);
394 /*************************************************************************/
397 * Notifies this frame that it should create its native peer.
403 peer = getToolkit ().createFrame (this);
407 /*************************************************************************/
410 * Destroys any resources associated with this frame. This includes
411 * all components in the frame and all owned toplevel windows.
416 Enumeration e = ownedWindows.elements();
417 while(e.hasMoreElements())
419 Window w = (Window)e.nextElement();
426 /*************************************************************************/
429 * Returns a debugging string describing this window.
431 * @return A debugging string describing this window.
436 return(getClass().getName());
442 /* FIXME: State might have changed in the peer... Must check. */
447 public static Frame[]
450 //Frame[] array = new Frames[frames.size()];
451 //return frames.toArray(array);
453 // see finalize() comment
454 String msg = "FIXME: can't be implemented without weak references";
455 throw new UnsupportedOperationException(msg);