001: /*
002: * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.awt;
027:
028: import java.awt.AWTException;
029: import java.awt.BufferCapabilities;
030: import java.awt.Color;
031: import java.awt.Component;
032: import java.awt.Cursor;
033: import java.awt.Dimension;
034: import java.awt.Font;
035: import java.awt.FontMetrics;
036: import java.awt.Graphics;
037: import java.awt.GraphicsConfiguration;
038: import java.awt.Image;
039: import java.awt.Insets;
040: import java.awt.MenuBar;
041: import java.awt.Point;
042: import java.awt.Event;
043: import java.awt.event.PaintEvent;
044: import java.awt.image.ColorModel;
045: import java.awt.image.ImageObserver;
046: import java.awt.image.ImageProducer;
047: import java.awt.image.VolatileImage;
048: import java.awt.peer.CanvasPeer;
049: import java.awt.peer.LightweightPeer;
050: import java.awt.peer.PanelPeer;
051: import java.awt.peer.ComponentPeer;
052: import java.awt.peer.ContainerPeer;
053: import java.awt.Rectangle;
054:
055: /**
056: * Implements the LightweightPeer interface for use in lightweight components
057: * that have no native window associated with them. This gets created by
058: * default in Component so that Component and Container can be directly
059: * extended to create useful components written entirely in java. These
060: * components must be hosted somewhere higher up in the component tree by a
061: * native container (such as a Frame).
062: *
063: * This implementation provides no useful semantics and serves only as a
064: * marker. One could provide alternative implementations in java that do
065: * something useful for some of the other peer interfaces to minimize the
066: * native code.
067: *
068: * This was renamed from java.awt.LightweightPeer (a horrible and confusing
069: * name) and moved from java.awt.Toolkit into sun.awt as a public class in
070: * its own file.
071: *
072: * @author Timothy Prinzing
073: * @author Michael Martak
074: */
075:
076: public class NullComponentPeer implements LightweightPeer, CanvasPeer,
077: PanelPeer {
078:
079: public boolean isObscured() {
080: return false;
081: }
082:
083: public boolean canDetermineObscurity() {
084: return false;
085: }
086:
087: public boolean isFocusable() {
088: return false;
089: }
090:
091: public void setVisible(boolean b) {
092: }
093:
094: public void show() {
095: }
096:
097: public void hide() {
098: }
099:
100: public void setEnabled(boolean b) {
101: }
102:
103: public void enable() {
104: }
105:
106: public void disable() {
107: }
108:
109: public void paint(Graphics g) {
110: }
111:
112: public void repaint(long tm, int x, int y, int width, int height) {
113: }
114:
115: public void print(Graphics g) {
116: }
117:
118: public void setBounds(int x, int y, int width, int height, int op) {
119: }
120:
121: public void reshape(int x, int y, int width, int height) {
122: }
123:
124: public void coalescePaintEvent(PaintEvent e) {
125: }
126:
127: public boolean handleEvent(Event e) {
128: return false;
129: }
130:
131: public void handleEvent(java.awt.AWTEvent arg0) {
132: }
133:
134: public Dimension getPreferredSize() {
135: return new Dimension(1, 1);
136: }
137:
138: public Dimension getMinimumSize() {
139: return new Dimension(1, 1);
140: }
141:
142: public java.awt.Toolkit getToolkit() {
143: return null;
144: }
145:
146: public ColorModel getColorModel() {
147: return null;
148: }
149:
150: public Graphics getGraphics() {
151: return null;
152: }
153:
154: public GraphicsConfiguration getGraphicsConfiguration() {
155: return null;
156: }
157:
158: public FontMetrics getFontMetrics(Font font) {
159: return null;
160: }
161:
162: public void dispose() {
163: // no native code
164: }
165:
166: public void setForeground(Color c) {
167: }
168:
169: public void setBackground(Color c) {
170: }
171:
172: public void setFont(Font f) {
173: }
174:
175: public void updateCursorImmediately() {
176: }
177:
178: public void setCursor(Cursor cursor) {
179: }
180:
181: public boolean requestFocus(Component lightweightChild,
182: boolean temporary, boolean focusedWindowChangeAllowed,
183: long time, CausedFocusEvent.Cause cause) {
184: return false;
185: }
186:
187: public Image createImage(ImageProducer producer) {
188: return null;
189: }
190:
191: public Image createImage(int width, int height) {
192: return null;
193: }
194:
195: public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
196: return false;
197: }
198:
199: public int checkImage(Image img, int w, int h, ImageObserver o) {
200: return 0;
201: }
202:
203: public Dimension preferredSize() {
204: return getPreferredSize();
205: }
206:
207: public Dimension minimumSize() {
208: return getMinimumSize();
209: }
210:
211: public Point getLocationOnScreen() {
212: return new Point(0, 0);
213: }
214:
215: public Insets getInsets() {
216: return insets();
217: }
218:
219: public void beginValidate() {
220: }
221:
222: public void endValidate() {
223: }
224:
225: public Insets insets() {
226: return new Insets(0, 0, 0, 0);
227: }
228:
229: public boolean isPaintPending() {
230: return false;
231: }
232:
233: public boolean handlesWheelScrolling() {
234: return false;
235: }
236:
237: public VolatileImage createVolatileImage(int width, int height) {
238: return null;
239: }
240:
241: public void beginLayout() {
242: }
243:
244: public void endLayout() {
245: }
246:
247: public void createBuffers(int numBuffers, BufferCapabilities caps)
248: throws AWTException {
249: throw new AWTException(
250: "Page-flipping is not allowed on a lightweight component");
251: }
252:
253: public Image getBackBuffer() {
254: throw new IllegalStateException(
255: "Page-flipping is not allowed on a lightweight component");
256: }
257:
258: public void flip(BufferCapabilities.FlipContents flipAction) {
259: throw new IllegalStateException(
260: "Page-flipping is not allowed on a lightweight component");
261: }
262:
263: public void destroyBuffers() {
264: }
265:
266: /**
267: * @see java.awt.peer.ComponentPeer#isReparentSupported
268: */
269: public boolean isReparentSupported() {
270: return false;
271: }
272:
273: /**
274: * @see java.awt.peer.ComponentPeer#reparent
275: */
276: public void reparent(ContainerPeer newNativeParent) {
277: throw new UnsupportedOperationException();
278: }
279:
280: /**
281: * @see java.awt.peer.ContainerPeer#restack
282: */
283: public void restack() {
284: throw new UnsupportedOperationException();
285: }
286:
287: /**
288: * @see java.awt.peer.ContainerPeer#isRestackSupported
289: */
290: public boolean isRestackSupported() {
291: return false;
292: }
293:
294: public void layout() {
295: }
296:
297: public Rectangle getBounds() {
298: return new Rectangle(0, 0, 0, 0);
299: }
300: }
|