source: trunk/gcc/libjava/javax/swing/JApplet.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.4 KB
Line 
1/* JApplet.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.applet.*;
41import java.awt.*;
42import java.awt.event.*;
43
44
45import javax.accessibility.AccessibleContext;
46import javax.accessibility.AccessibleRole;
47import javax.accessibility.AccessibleState;
48import javax.accessibility.AccessibleStateSet;
49
50
51public class JApplet extends Applet
52{
53
54 public final static int HIDE_ON_CLOSE = 0;
55 public final static int EXIT_ON_CLOSE = 1;
56 public final static int DISPOSE_ON_CLOSE = 2;
57 public final static int DO_NOTHING_ON_CLOSE = 3;
58
59 private int close_action = EXIT_ON_CLOSE;
60 private boolean checking;
61 protected JRootPane rootPane;
62
63 public JApplet()
64 {
65 frameInit();
66 }
67
68 public JApplet(String title)
69 {
70 frameInit();
71 }
72
73 protected void frameInit()
74 {
75 super.setLayout(new BorderLayout(1, 1));
76 getRootPane(); // will do set/create
77 }
78
79 public Dimension getPreferredSize()
80 {
81 Dimension d = super.getPreferredSize();
82 System.out.println("JFrame.getPrefSize(): " + d + " , comp="+countComponents() + ", layout=" + getLayout());
83 return d;
84 }
85
86 public void setLayout(LayoutManager manager)
87 { super.setLayout(manager); }
88
89 void setLayeredPane(JLayeredPane layeredPane)
90 { getRootPane().setLayeredPane(layeredPane); }
91
92 JLayeredPane getLayeredPane()
93 { return getRootPane().getLayeredPane(); }
94
95 JRootPane getRootPane()
96 {
97 if (rootPane == null)
98 setRootPane(createRootPane());
99 return rootPane;
100 }
101
102 void setRootPane(JRootPane root)
103 {
104 if (rootPane != null)
105 remove(rootPane);
106
107 rootPane = root;
108 add(rootPane, BorderLayout.CENTER);
109 }
110
111 JRootPane createRootPane()
112 { return new JRootPane(); }
113
114 Container getContentPane()
115 { return getRootPane().getContentPane(); }
116
117 void setContentPane(Container contentPane)
118 { getRootPane().setContentPane(contentPane); }
119
120 Component getGlassPane()
121 { return getRootPane().getGlassPane(); }
122
123 void setGlassPane(Component glassPane)
124 { getRootPane().setGlassPane(glassPane); }
125
126
127 /////////////////////////////////////////////////////////////////////////////////
128 protected void addImpl(Component comp, Object constraints, int index)
129 { super.addImpl(comp, constraints, index); }
130
131 public AccessibleContext getAccessibleContext()
132 { return null; }
133
134 int getDefaultCloseOperation()
135 { return close_action; }
136
137
138 JMenuBar getJMenuBar()
139 { return getRootPane().getJMenuBar(); }
140
141 void setJMenuBar(JMenuBar menubar)
142 { getRootPane().setJMenuBar(menubar); }
143
144
145 protected String paramString()
146 { return "JFrame"; }
147
148 protected void processKeyEvent(KeyEvent e)
149 { super.processKeyEvent(e); }
150
151 protected void processWindowEvent(WindowEvent e)
152 {
153 // System.out.println("PROCESS_WIN_EV-1: " + e);
154
155 // super.processWindowEvent(e);
156
157 // System.out.println("PROCESS_WIN_EV-2: " + e);
158 switch (e.getID())
159 {
160 case WindowEvent.WINDOW_CLOSING:
161 {
162 switch(close_action)
163 {
164 case EXIT_ON_CLOSE:
165 {
166 System.out.println("user requested exit on close");
167 System.exit(1);
168 break;
169 }
170 case DISPOSE_ON_CLOSE:
171 {
172 System.out.println("user requested dispose on close");
173 //dispose();
174 break;
175 }
176 case HIDE_ON_CLOSE:
177
178 case DO_NOTHING_ON_CLOSE:
179 break;
180 }
181 break;
182 }
183
184 case WindowEvent.WINDOW_CLOSED:
185 case WindowEvent.WINDOW_OPENED:
186 case WindowEvent.WINDOW_ICONIFIED:
187 case WindowEvent.WINDOW_DEICONIFIED:
188 case WindowEvent.WINDOW_ACTIVATED:
189 case WindowEvent.WINDOW_DEACTIVATED:
190 break;
191 }
192 }
193
194
195 public void remove(Component comp)
196 { getContentPane().remove(comp); }
197
198
199 void setDefaultCloseOperation(int operation)
200 { close_action = operation; }
201
202
203
204 protected boolean isRootPaneCheckingEnabled()
205 { return checking; }
206
207
208 protected void setRootPaneCheckingEnabled(boolean enabled)
209 { checking = enabled; }
210
211 public void update(Graphics g)
212 { paint(g); }
213}
Note: See TracBrowser for help on using the repository browser.