|
1 /* |
|
2 * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 package sun.awt; |
|
27 |
|
28 import java.awt.AWTException; |
|
29 import java.awt.BufferCapabilities; |
|
30 import java.awt.Color; |
|
31 import java.awt.Component; |
|
32 import java.awt.Cursor; |
|
33 import java.awt.Dimension; |
|
34 import java.awt.Font; |
|
35 import java.awt.FontMetrics; |
|
36 import java.awt.Graphics; |
|
37 import java.awt.GraphicsConfiguration; |
|
38 import java.awt.Image; |
|
39 import java.awt.Insets; |
|
40 import java.awt.MenuBar; |
|
41 import java.awt.Point; |
|
42 import java.awt.Event; |
|
43 import java.awt.event.PaintEvent; |
|
44 import java.awt.image.ColorModel; |
|
45 import java.awt.image.ImageObserver; |
|
46 import java.awt.image.ImageProducer; |
|
47 import java.awt.image.VolatileImage; |
|
48 import java.awt.peer.CanvasPeer; |
|
49 import java.awt.peer.LightweightPeer; |
|
50 import java.awt.peer.PanelPeer; |
|
51 import java.awt.peer.ComponentPeer; |
|
52 import java.awt.peer.ContainerPeer; |
|
53 import java.awt.Rectangle; |
|
54 import sun.java2d.pipe.Region; |
|
55 |
|
56 |
|
57 /** |
|
58 * Implements the LightweightPeer interface for use in lightweight components |
|
59 * that have no native window associated with them. This gets created by |
|
60 * default in Component so that Component and Container can be directly |
|
61 * extended to create useful components written entirely in java. These |
|
62 * components must be hosted somewhere higher up in the component tree by a |
|
63 * native container (such as a Frame). |
|
64 * |
|
65 * This implementation provides no useful semantics and serves only as a |
|
66 * marker. One could provide alternative implementations in java that do |
|
67 * something useful for some of the other peer interfaces to minimize the |
|
68 * native code. |
|
69 * |
|
70 * This was renamed from java.awt.LightweightPeer (a horrible and confusing |
|
71 * name) and moved from java.awt.Toolkit into sun.awt as a public class in |
|
72 * its own file. |
|
73 * |
|
74 * @author Timothy Prinzing |
|
75 * @author Michael Martak |
|
76 */ |
|
77 |
|
78 public class NullComponentPeer implements LightweightPeer, |
|
79 CanvasPeer, PanelPeer { |
|
80 |
|
81 public boolean isObscured() { |
|
82 return false; |
|
83 } |
|
84 |
|
85 public boolean canDetermineObscurity() { |
|
86 return false; |
|
87 } |
|
88 |
|
89 public boolean isFocusable() { |
|
90 return false; |
|
91 } |
|
92 |
|
93 public void setVisible(boolean b) { |
|
94 } |
|
95 |
|
96 public void show() { |
|
97 } |
|
98 |
|
99 public void hide() { |
|
100 } |
|
101 |
|
102 public void setEnabled(boolean b) { |
|
103 } |
|
104 |
|
105 public void enable() { |
|
106 } |
|
107 |
|
108 public void disable() { |
|
109 } |
|
110 |
|
111 public void paint(Graphics g) { |
|
112 } |
|
113 |
|
114 public void repaint(long tm, int x, int y, int width, int height) { |
|
115 } |
|
116 |
|
117 public void print(Graphics g) { |
|
118 } |
|
119 |
|
120 public void setBounds(int x, int y, int width, int height, int op) { |
|
121 } |
|
122 |
|
123 public void reshape(int x, int y, int width, int height) { |
|
124 } |
|
125 |
|
126 public void coalescePaintEvent(PaintEvent e) { |
|
127 } |
|
128 |
|
129 public boolean handleEvent(Event e) { |
|
130 return false; |
|
131 } |
|
132 |
|
133 public void handleEvent(java.awt.AWTEvent arg0) { |
|
134 } |
|
135 |
|
136 public Dimension getPreferredSize() { |
|
137 return new Dimension(1,1); |
|
138 } |
|
139 |
|
140 public Dimension getMinimumSize() { |
|
141 return new Dimension(1,1); |
|
142 } |
|
143 |
|
144 public java.awt.Toolkit getToolkit() { |
|
145 return null; |
|
146 } |
|
147 |
|
148 public ColorModel getColorModel() { |
|
149 return null; |
|
150 } |
|
151 |
|
152 public Graphics getGraphics() { |
|
153 return null; |
|
154 } |
|
155 |
|
156 public GraphicsConfiguration getGraphicsConfiguration() { |
|
157 return null; |
|
158 } |
|
159 |
|
160 public FontMetrics getFontMetrics(Font font) { |
|
161 return null; |
|
162 } |
|
163 |
|
164 public void dispose() { |
|
165 // no native code |
|
166 } |
|
167 |
|
168 public void setForeground(Color c) { |
|
169 } |
|
170 |
|
171 public void setBackground(Color c) { |
|
172 } |
|
173 |
|
174 public void setFont(Font f) { |
|
175 } |
|
176 |
|
177 public void updateCursorImmediately() { |
|
178 } |
|
179 |
|
180 public void setCursor(Cursor cursor) { |
|
181 } |
|
182 |
|
183 public boolean requestFocus |
|
184 (Component lightweightChild, boolean temporary, |
|
185 boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause) { |
|
186 return false; |
|
187 } |
|
188 |
|
189 public Image createImage(ImageProducer producer) { |
|
190 return null; |
|
191 } |
|
192 |
|
193 public Image createImage(int width, int height) { |
|
194 return null; |
|
195 } |
|
196 |
|
197 public boolean prepareImage(Image img, int w, int h, ImageObserver o) { |
|
198 return false; |
|
199 } |
|
200 |
|
201 public int checkImage(Image img, int w, int h, ImageObserver o) { |
|
202 return 0; |
|
203 } |
|
204 |
|
205 public Dimension preferredSize() { |
|
206 return getPreferredSize(); |
|
207 } |
|
208 |
|
209 public Dimension minimumSize() { |
|
210 return getMinimumSize(); |
|
211 } |
|
212 |
|
213 public Point getLocationOnScreen() { |
|
214 return new Point(0,0); |
|
215 } |
|
216 |
|
217 public Insets getInsets() { |
|
218 return insets(); |
|
219 } |
|
220 |
|
221 public void beginValidate() { |
|
222 } |
|
223 |
|
224 public void endValidate() { |
|
225 } |
|
226 |
|
227 public Insets insets() { |
|
228 return new Insets(0, 0, 0, 0); |
|
229 } |
|
230 |
|
231 public boolean isPaintPending() { |
|
232 return false; |
|
233 } |
|
234 |
|
235 public boolean handlesWheelScrolling() { |
|
236 return false; |
|
237 } |
|
238 |
|
239 public VolatileImage createVolatileImage(int width, int height) { |
|
240 return null; |
|
241 } |
|
242 |
|
243 public void beginLayout() { |
|
244 } |
|
245 |
|
246 public void endLayout() { |
|
247 } |
|
248 |
|
249 public void createBuffers(int numBuffers, BufferCapabilities caps) |
|
250 throws AWTException { |
|
251 throw new AWTException( |
|
252 "Page-flipping is not allowed on a lightweight component"); |
|
253 } |
|
254 public Image getBackBuffer() { |
|
255 throw new IllegalStateException( |
|
256 "Page-flipping is not allowed on a lightweight component"); |
|
257 } |
|
258 public void flip(BufferCapabilities.FlipContents flipAction) { |
|
259 throw new IllegalStateException( |
|
260 "Page-flipping is not allowed on a lightweight component"); |
|
261 } |
|
262 public void destroyBuffers() { |
|
263 } |
|
264 |
|
265 /** |
|
266 * @see java.awt.peer.ComponentPeer#isReparentSupported |
|
267 */ |
|
268 public boolean isReparentSupported() { |
|
269 return false; |
|
270 } |
|
271 |
|
272 /** |
|
273 * @see java.awt.peer.ComponentPeer#reparent |
|
274 */ |
|
275 public void reparent(ContainerPeer newNativeParent) { |
|
276 throw new UnsupportedOperationException(); |
|
277 } |
|
278 |
|
279 /** |
|
280 * @see java.awt.peer.ContainerPeer#restack |
|
281 */ |
|
282 public void restack() { |
|
283 throw new UnsupportedOperationException(); |
|
284 } |
|
285 |
|
286 /** |
|
287 * @see java.awt.peer.ContainerPeer#isRestackSupported |
|
288 */ |
|
289 public boolean isRestackSupported() { |
|
290 return false; |
|
291 } |
|
292 public void layout() { |
|
293 } |
|
294 |
|
295 public Rectangle getBounds() { |
|
296 return new Rectangle(0, 0, 0, 0); |
|
297 } |
|
298 |
|
299 |
|
300 /** |
|
301 * Applies the shape to the native component window. |
|
302 * @since 1.7 |
|
303 */ |
|
304 public void applyShape(Region shape) { |
|
305 } |
|
306 } |