source: trunk/src/gcc/libjava/java/awt/Frame.java@ 154

Last change on this file since 154 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 11.2 KB
Line 
1/* Frame.java -- AWT toplevel window
2 Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38
39package java.awt;
40
41import java.awt.peer.FramePeer;
42import java.awt.peer.WindowPeer;
43import java.awt.peer.ContainerPeer;
44import java.awt.peer.ComponentPeer;
45import java.io.Serializable;
46import java.util.Enumeration;
47import java.util.Vector;
48
49/**
50 * This class is a top-level window with a title bar and window
51 * decorations.
52 *
53 * @author Aaron M. Renn ([email protected])
54 */
55public class Frame extends Window implements MenuContainer, Serializable
56{
57
58/*
59 * Static Variables
60 */
61
62/**
63 * Constant for a cross-hair cursor.
64 * @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
65 */
66public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
67
68/**
69 * Constant for a cursor over a text field.
70 * @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
71 */
72public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
73
74/**
75 * Constant for a cursor to display while waiting for an action to complete.
76 * @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
77 */
78public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
79
80/**
81 * Cursor used over SW corner of window decorations.
82 * @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
83 */
84public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
85
86/**
87 * Cursor used over SE corner of window decorations.
88 * @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
89 */
90public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
91
92/**
93 * Cursor used over NW corner of window decorations.
94 * @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
95 */
96public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
97
98/**
99 * Cursor used over NE corner of window decorations.
100 * @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
101 */
102public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
103
104/**
105 * Cursor used over N edge of window decorations.
106 * @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
107 */
108public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
109
110/**
111 * Cursor used over S edge of window decorations.
112 * @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
113 */
114public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
115
116/**
117 * Cursor used over E edge of window decorations.
118 * @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
119 */
120public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
121
122/**
123 * Cursor used over W edge of window decorations.
124 * @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
125 */
126public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
127
128/**
129 * Constant for a hand cursor.
130 * @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
131 */
132public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
133
134/**
135 * Constant for a cursor used during window move operations.
136 * @deprecated Use <code>Cursor.MOVE_CURSOR</code> instead.
137 */
138public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
139
140// Serialization version constant
141private static final long serialVersionUID = 2673458971256075116L;
142
143/*************************************************************************/
144
145/*
146 * Instance Variables
147 */
148
149/**
150 * @serial The version of the class data being serialized
151 * // FIXME: what is this value?
152 */
153private int frameSerializedDataVersion;
154
155/**
156 * @serial Image used as the icon when this frame is minimized.
157 */
158private Image icon;
159
160/**
161 * @serial Constant used by the JDK Motif peer set. Not used in
162 * this implementation.
163 */
164private boolean mbManagement;
165
166/**
167 * @serial The menu bar for this frame.
168 */
169//private MenuBar menuBar = new MenuBar();
170private MenuBar menuBar;
171
172/**
173 * @serial A list of other top-level windows owned by this window.
174 */
175Vector ownedWindows = new Vector();
176
177/**
178 * @serial Indicates whether or not this frame is resizable.
179 */
180private boolean resizable = true;
181
182/**
183 * @serial The state of this frame.
184 * // FIXME: What are the values here?
185 */
186private int state;
187
188/**
189 * @serial The title of the frame.
190 */
191private String title = "";
192
193/*************************************************************************/
194
195/*
196 * Constructors
197 */
198
199/**
200 * Initializes a new instance of <code>Frame</code> that is not visible
201 * and has no title.
202 */
203public
204Frame()
205{
206 this("");
207}
208
209/*************************************************************************/
210
211/**
212 * Initializes a new instance of <code>Frame</code> that is not visible
213 * and has the specified title.
214 *
215 * @param title The title of this frame.
216 */
217public
218Frame(String title)
219{
220 super();
221 System.err.println("returned");
222 this.title = title;
223 System.err.println("end");
224}
225
226public
227Frame(GraphicsConfiguration gc)
228{
229 super(gc);
230}
231
232public
233Frame(String title, GraphicsConfiguration gc)
234{
235 super(gc);
236 setTitle(title);
237}
238
239/*************************************************************************/
240
241/*
242 * Instance Methods
243 */
244
245/**
246 * Returns this frame's title string.
247 *
248 * @return This frame's title string.
249 */
250public String
251getTitle()
252{
253 return(title);
254}
255
256/*************************************************************************/
257
258/*
259 * Sets this frame's title to the specified value.
260 *
261 * @param title The new frame title.
262 */
263public synchronized void
264setTitle(String title)
265{
266 this.title = title;
267 if (peer != null)
268 ((FramePeer) peer).setTitle(title);
269}
270
271/*************************************************************************/
272
273/**
274 * Returns this frame's icon.
275 *
276 * @return This frame's icon, or <code>null</code> if this frame does not
277 * have an icon.
278 */
279public Image
280getIconImage()
281{
282 return(icon);
283}
284
285/*************************************************************************/
286
287/**
288 * Sets this frame's icon to the specified value.
289 *
290 * @icon The new icon for this frame.
291 */
292public synchronized void
293setIconImage(Image icon)
294{
295 this.icon = icon;
296 if (peer != null)
297 ((FramePeer) peer).setIconImage(icon);
298}
299
300/*************************************************************************/
301
302/**
303 * Returns this frame's menu bar.
304 *
305 * @return This frame's menu bar, or <code>null</code> if this frame
306 * does not have a menu bar.
307 */
308public MenuBar
309getMenuBar()
310{
311 return(menuBar);
312}
313
314/*************************************************************************/
315
316/**
317 * Sets this frame's menu bar.
318 *
319 * @param menuBar The new menu bar for this frame.
320 */
321public synchronized void
322setMenuBar(MenuBar menuBar)
323{
324 this.menuBar = menuBar;
325 if (peer != null)
326 ((FramePeer) peer).setMenuBar(menuBar);
327}
328
329/*************************************************************************/
330
331/**
332 * Tests whether or not this frame is resizable. This will be
333 * <code>true</code> by default.
334 *
335 * @return <code>true</code> if this frame is resizable, <code>false</code>
336 * otherwise.
337 */
338public boolean
339isResizable()
340{
341 return(resizable);
342}
343
344/*************************************************************************/
345
346/**
347 * Sets the resizability of this frame to the specified value.
348 *
349 * @param resizable <code>true</code> to make the frame resizable,
350 * <code>false</code> to make it non-resizable.
351 */
352public synchronized void
353setResizable(boolean resizable)
354{
355 this.resizable = resizable;
356 if (peer != null)
357 ((FramePeer) peer).setResizable(resizable);
358}
359
360/*************************************************************************/
361
362/**
363 * Returns the cursor type of the cursor for this window. This will
364 * be one of the constants in this class.
365 *
366 * @return The cursor type for this frame.
367 *
368 * @deprecated Use <code>Component.getCursor()</code> instead.
369 */
370public int
371getCursorType()
372{
373 return(getCursor().getType());
374}
375
376/*************************************************************************/
377
378/**
379 * Sets the cursor for this window to the specified type. The specified
380 * type should be one of the constants in this class.
381 *
382 * @param type The cursor type.
383 *
384 * @deprecated. Use <code>Component.setCursor(Cursor)</code> instead.
385 */
386public void
387setCursor(int type)
388{
389 setCursor(new Cursor(type));
390}
391
392/*************************************************************************/
393
394/**
395 * Removes the specified component from this frame's menu.
396 *
397 * @param menu The menu component to remove.
398 */
399public void
400remove(MenuComponent menu)
401{
402 menuBar.remove(menu);
403}
404
405/*************************************************************************/
406
407/**
408 * Notifies this frame that it should create its native peer.
409 */
410public void
411addNotify()
412{
413 if (peer == null)
414 peer = getToolkit ().createFrame (this);
415 super.addNotify();
416}
417
418/*************************************************************************/
419
420/**
421 * Destroys any resources associated with this frame. This includes
422 * all components in the frame and all owned toplevel windows.
423 */
424public void
425dispose()
426{
427 Enumeration e = ownedWindows.elements();
428 while(e.hasMoreElements())
429 {
430 Window w = (Window)e.nextElement();
431 w.dispose();
432 }
433
434 super.dispose();
435}
436
437/*************************************************************************/
438
439/**
440 * Returns a debugging string describing this window.
441 *
442 * @return A debugging string describing this window.
443 */
444protected String
445paramString()
446{
447 return(getClass().getName());
448}
449
450public int
451getState()
452{
453 /* FIXME: State might have changed in the peer... Must check. */
454
455 return state;
456}
457
458public static Frame[]
459getFrames()
460{
461 //Frame[] array = new Frames[frames.size()];
462 //return frames.toArray(array);
463
464 // see finalize() comment
465 String msg = "FIXME: can't be implemented without weak references";
466 throw new UnsupportedOperationException(msg);
467}
468
469} // class Frame
470
Note: See TracBrowser for help on using the repository browser.