source: trunk/gcc/libjava/java/awt/Frame.java

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 11.5 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 (arenn@urbanophile.com)
54 */
55public class Frame extends Window implements MenuContainer, Serializable
56{
57
58/*
59 * Static Variables
60 */
61
62/**
63 * Constant for the default cursor.
64 * Deprecated. replaced by <code>Cursor.DEFAULT_CURSOR</code> instead.
65 */
66public static final int DEFAULT_CURSOR = Cursor.DEFAULT_CURSOR;
67
68/**
69 * Constant for a cross-hair cursor.
70 * @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
71 */
72public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
73
74/**
75 * Constant for a cursor over a text field.
76 * @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
77 */
78public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
79
80/**
81 * Constant for a cursor to display while waiting for an action to complete.
82 * @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
83 */
84public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
85
86/**
87 * Cursor used over SW corner of window decorations.
88 * @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
89 */
90public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
91
92/**
93 * Cursor used over SE corner of window decorations.
94 * @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
95 */
96public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
97
98/**
99 * Cursor used over NW corner of window decorations.
100 * @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
101 */
102public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
103
104/**
105 * Cursor used over NE corner of window decorations.
106 * @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
107 */
108public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
109
110/**
111 * Cursor used over N edge of window decorations.
112 * @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
113 */
114public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
115
116/**
117 * Cursor used over S edge of window decorations.
118 * @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
119 */
120public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
121
122/**
123 * Cursor used over E edge of window decorations.
124 * @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
125 */
126public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
127
128/**
129 * Cursor used over W edge of window decorations.
130 * @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
131 */
132public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
133
134/**
135 * Constant for a hand cursor.
136 * @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
137 */
138public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
139
140/**
141 * Constant for a cursor used during window move operations.
142 * @deprecated Use <code>Cursor.MOVE_CURSOR</code> instead.
143 */
144public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
145
146public static final int ICONIFIED = 1;
147public static final int MAXIMIZED_BOTH = 6;
148public static final int MAXIMIZED_HORIZ = 2;
149public static final int MAXIMIZED_VERT = 4;
150public static final int NORMAL = 0;
151
152// Serialization version constant
153private static final long serialVersionUID = 2673458971256075116L;
154
155/*************************************************************************/
156
157/*
158 * Instance Variables
159 */
160
161/**
162 * @serial The version of the class data being serialized
163 * // FIXME: what is this value?
164 */
165private int frameSerializedDataVersion;
166
167/**
168 * @serial Image used as the icon when this frame is minimized.
169 */
170private Image icon;
171
172/**
173 * @serial Constant used by the JDK Motif peer set. Not used in
174 * this implementation.
175 */
176private boolean mbManagement;
177
178/**
179 * @serial The menu bar for this frame.
180 */
181//private MenuBar menuBar = new MenuBar();
182private MenuBar menuBar;
183
184/**
185 * @serial A list of other top-level windows owned by this window.
186 */
187Vector ownedWindows = new Vector();
188
189/**
190 * @serial Indicates whether or not this frame is resizable.
191 */
192private boolean resizable = true;
193
194/**
195 * @serial The state of this frame.
196 * // FIXME: What are the values here?
197 */
198private int state;
199
200/**
201 * @serial The title of the frame.
202 */
203private String title = "";
204
205/*************************************************************************/
206
207/*
208 * Constructors
209 */
210
211/**
212 * Initializes a new instance of <code>Frame</code> that is not visible
213 * and has no title.
214 */
215public
216Frame()
217{
218 this("");
219}
220
221/*************************************************************************/
222
223/**
224 * Initializes a new instance of <code>Frame</code> that is not visible
225 * and has the specified title.
226 *
227 * @param title The title of this frame.
228 */
229public
230Frame(String title)
231{
232 super();
233 this.title = title;
234}
235
236public
237Frame(GraphicsConfiguration gc)
238{
239 super(gc);
240}
241
242public
243Frame(String title, GraphicsConfiguration gc)
244{
245 super(gc);
246 setTitle(title);
247}
248
249/*************************************************************************/
250
251/*
252 * Instance Methods
253 */
254
255/**
256 * Returns this frame's title string.
257 *
258 * @return This frame's title string.
259 */
260public String
261getTitle()
262{
263 return(title);
264}
265
266/*************************************************************************/
267
268/*
269 * Sets this frame's title to the specified value.
270 *
271 * @param title The new frame title.
272 */
273public synchronized void
274setTitle(String title)
275{
276 this.title = title;
277 if (peer != null)
278 ((FramePeer) peer).setTitle(title);
279}
280
281/*************************************************************************/
282
283/**
284 * Returns this frame's icon.
285 *
286 * @return This frame's icon, or <code>null</code> if this frame does not
287 * have an icon.
288 */
289public Image
290getIconImage()
291{
292 return(icon);
293}
294
295/*************************************************************************/
296
297/**
298 * Sets this frame's icon to the specified value.
299 *
300 * @icon The new icon for this frame.
301 */
302public synchronized void
303setIconImage(Image icon)
304{
305 this.icon = icon;
306 if (peer != null)
307 ((FramePeer) peer).setIconImage(icon);
308}
309
310/*************************************************************************/
311
312/**
313 * Returns this frame's menu bar.
314 *
315 * @return This frame's menu bar, or <code>null</code> if this frame
316 * does not have a menu bar.
317 */
318public MenuBar
319getMenuBar()
320{
321 return(menuBar);
322}
323
324/*************************************************************************/
325
326/**
327 * Sets this frame's menu bar.
328 *
329 * @param menuBar The new menu bar for this frame.
330 */
331public synchronized void
332setMenuBar(MenuBar menuBar)
333{
334 this.menuBar = menuBar;
335 if (peer != null)
336 ((FramePeer) peer).setMenuBar(menuBar);
337}
338
339/*************************************************************************/
340
341/**
342 * Tests whether or not this frame is resizable. This will be
343 * <code>true</code> by default.
344 *
345 * @return <code>true</code> if this frame is resizable, <code>false</code>
346 * otherwise.
347 */
348public boolean
349isResizable()
350{
351 return(resizable);
352}
353
354/*************************************************************************/
355
356/**
357 * Sets the resizability of this frame to the specified value.
358 *
359 * @param resizable <code>true</code> to make the frame resizable,
360 * <code>false</code> to make it non-resizable.
361 */
362public synchronized void
363setResizable(boolean resizable)
364{
365 this.resizable = resizable;
366 if (peer != null)
367 ((FramePeer) peer).setResizable(resizable);
368}
369
370/*************************************************************************/
371
372/**
373 * Returns the cursor type of the cursor for this window. This will
374 * be one of the constants in this class.
375 *
376 * @return The cursor type for this frame.
377 *
378 * @deprecated Use <code>Component.getCursor()</code> instead.
379 */
380public int
381getCursorType()
382{
383 return(getCursor().getType());
384}
385
386/*************************************************************************/
387
388/**
389 * Sets the cursor for this window to the specified type. The specified
390 * type should be one of the constants in this class.
391 *
392 * @param type The cursor type.
393 *
394 * @deprecated. Use <code>Component.setCursor(Cursor)</code> instead.
395 */
396public void
397setCursor(int type)
398{
399 setCursor(new Cursor(type));
400}
401
402/*************************************************************************/
403
404/**
405 * Removes the specified component from this frame's menu.
406 *
407 * @param menu The menu component to remove.
408 */
409public void
410remove(MenuComponent menu)
411{
412 menuBar.remove(menu);
413}
414
415/*************************************************************************/
416
417/**
418 * Notifies this frame that it should create its native peer.
419 */
420public void
421addNotify()
422{
423 if (peer == null)
424 peer = getToolkit ().createFrame (this);
425 super.addNotify();
426}
427
428/*************************************************************************/
429
430/**
431 * Destroys any resources associated with this frame. This includes
432 * all components in the frame and all owned toplevel windows.
433 */
434public void
435dispose()
436{
437 Enumeration e = ownedWindows.elements();
438 while(e.hasMoreElements())
439 {
440 Window w = (Window)e.nextElement();
441 w.dispose();
442 }
443
444 super.dispose();
445}
446
447/*************************************************************************/
448
449/**
450 * Returns a debugging string describing this window.
451 *
452 * @return A debugging string describing this window.
453 */
454protected String
455paramString()
456{
457 return(getClass().getName());
458}
459
460public int
461getState()
462{
463 /* FIXME: State might have changed in the peer... Must check. */
464
465 return state;
466}
467
468public static Frame[]
469getFrames()
470{
471 //Frame[] array = new Frames[frames.size()];
472 //return frames.toArray(array);
473
474 // see finalize() comment
475 String msg = "FIXME: can't be implemented without weak references";
476 throw new UnsupportedOperationException(msg);
477}
478
479} // class Frame
480
Note: See TracBrowser for help on using the repository browser.