source: trunk/gcc/libjava/javax/swing/JWindow.java

Last change on this file was 1389, checked in by bird, 21 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: 6.0 KB
Line 
1/* JWindow.java --
2 Copyright (C) 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
38package javax.swing;
39
40import java.awt.*;
41import java.awt.event.*;
42import javax.accessibility.*;
43
44/**
45 * Unlike JComponent derivatives, JWindow inherits from
46 * java.awt.Window. But also lets a look-and-feel component to its work.
47 *
48 * @author Ronald Veldema (rveldema@cs.vu.nl)
49 */
50public class JWindow extends Window implements Accessible
51{
52 public final static int HIDE_ON_CLOSE = 0;
53 public final static int EXIT_ON_CLOSE = 1;
54 public final static int DISPOSE_ON_CLOSE = 2;
55 public final static int DO_NOTHING_ON_CLOSE = 3;
56
57 protected AccessibleContext accessibleContext;
58
59 private int close_action = EXIT_ON_CLOSE;
60
61
62 /***************************************************
63 *
64 *
65 * constructors
66 *
67 *
68 *************/
69
70 // huuu ?
71 public JWindow(Frame f)
72 {
73 super(f);
74 }
75
76 /***************************************************
77 *
78 *
79 * methods, this part is shared with JDialog, JFrame
80 *
81 *
82 *************/
83
84
85 private boolean checking;
86 protected JRootPane rootPane;
87
88
89 protected void frameInit()
90 {
91 super.setLayout(new BorderLayout(1, 1));
92 getRootPane(); // will do set/create
93 }
94
95 public Dimension getPreferredSize()
96 {
97 Dimension d = super.getPreferredSize();
98 return d;
99 }
100
101 JMenuBar getJMenuBar()
102 { return getRootPane().getJMenuBar(); }
103
104 void setJMenuBar(JMenuBar menubar)
105 { getRootPane().setJMenuBar(menubar); }
106
107
108 public void setLayout(LayoutManager manager)
109 { super.setLayout(manager); }
110
111 void setLayeredPane(JLayeredPane layeredPane)
112 { getRootPane().setLayeredPane(layeredPane); }
113
114 JLayeredPane getLayeredPane()
115 { return getRootPane().getLayeredPane(); }
116
117 JRootPane getRootPane()
118 {
119 if (rootPane == null)
120 setRootPane(createRootPane());
121 return rootPane;
122 }
123
124 void setRootPane(JRootPane root)
125 {
126 if (rootPane != null)
127 remove(rootPane);
128
129 rootPane = root;
130 add(rootPane, BorderLayout.CENTER);
131 }
132
133 JRootPane createRootPane()
134 { return new JRootPane(); }
135
136 Container getContentPane()
137 { return getRootPane().getContentPane(); }
138
139 void setContentPane(Container contentPane)
140 { getRootPane().setContentPane(contentPane); }
141
142 Component getGlassPane()
143 { return getRootPane().getGlassPane(); }
144
145 void setGlassPane(Component glassPane)
146 { getRootPane().setGlassPane(glassPane); }
147
148
149 protected void addImpl(Component comp, Object constraints, int index)
150 { super.addImpl(comp, constraints, index); }
151
152
153 public void remove(Component comp)
154 { getContentPane().remove(comp); }
155
156 protected boolean isRootPaneCheckingEnabled()
157 { return checking; }
158
159
160 protected void setRootPaneCheckingEnabled(boolean enabled)
161 { checking = enabled; }
162
163
164 public void update(Graphics g)
165 { paint(g); }
166
167 protected void processKeyEvent(KeyEvent e)
168 { super.processKeyEvent(e); }
169
170 /////////////////////////////////////////////////////////////////////////////////
171
172 public AccessibleContext getAccessibleContext()
173 { return null; }
174
175 int getDefaultCloseOperation()
176 { return close_action; }
177
178 protected String paramString()
179 { return "JWindow"; }
180
181
182 protected void processWindowEvent(WindowEvent e)
183 {
184 // System.out.println("PROCESS_WIN_EV-1: " + e);
185 super.processWindowEvent(e);
186 // System.out.println("PROCESS_WIN_EV-2: " + e);
187 switch (e.getID())
188 {
189 case WindowEvent.WINDOW_CLOSING:
190 {
191 switch(close_action)
192 {
193 case EXIT_ON_CLOSE:
194 {
195 System.out.println("user requested exit on close");
196 System.exit(1);
197 break;
198 }
199 case DISPOSE_ON_CLOSE:
200 {
201 System.out.println("user requested dispose on close");
202 dispose();
203 break;
204 }
205 case HIDE_ON_CLOSE:
206 {
207 setVisible(false);
208 break;
209 }
210 case DO_NOTHING_ON_CLOSE:
211 break;
212 }
213 break;
214 }
215
216 case WindowEvent.WINDOW_CLOSED:
217 case WindowEvent.WINDOW_OPENED:
218 case WindowEvent.WINDOW_ICONIFIED:
219 case WindowEvent.WINDOW_DEICONIFIED:
220 case WindowEvent.WINDOW_ACTIVATED:
221 case WindowEvent.WINDOW_DEACTIVATED:
222 break;
223 }
224 }
225
226
227 void setDefaultCloseOperation(int operation)
228 { close_action = operation; }
229
230}
Note: See TracBrowser for help on using the repository browser.