Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/awt/NullComponentPeer.java
38827 views
/*1* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.awt;2627import java.awt.AWTException;28import java.awt.BufferCapabilities;29import java.awt.Color;30import java.awt.Component;31import java.awt.Cursor;32import java.awt.Dimension;33import java.awt.Font;34import java.awt.FontMetrics;35import java.awt.Graphics;36import java.awt.GraphicsConfiguration;37import java.awt.Image;38import java.awt.Insets;39import java.awt.MenuBar;40import java.awt.Point;41import java.awt.Event;42import java.awt.event.PaintEvent;43import java.awt.image.ColorModel;44import java.awt.image.ImageObserver;45import java.awt.image.ImageProducer;46import java.awt.image.VolatileImage;47import java.awt.peer.CanvasPeer;48import java.awt.peer.LightweightPeer;49import java.awt.peer.PanelPeer;50import java.awt.peer.ComponentPeer;51import java.awt.peer.ContainerPeer;52import java.awt.Rectangle;53import sun.java2d.pipe.Region;545556/**57* Implements the LightweightPeer interface for use in lightweight components58* that have no native window associated with them. This gets created by59* default in Component so that Component and Container can be directly60* extended to create useful components written entirely in java. These61* components must be hosted somewhere higher up in the component tree by a62* native container (such as a Frame).63*64* This implementation provides no useful semantics and serves only as a65* marker. One could provide alternative implementations in java that do66* something useful for some of the other peer interfaces to minimize the67* native code.68*69* This was renamed from java.awt.LightweightPeer (a horrible and confusing70* name) and moved from java.awt.Toolkit into sun.awt as a public class in71* its own file.72*73* @author Timothy Prinzing74* @author Michael Martak75*/7677public class NullComponentPeer implements LightweightPeer,78CanvasPeer, PanelPeer {7980public boolean isObscured() {81return false;82}8384public boolean canDetermineObscurity() {85return false;86}8788public boolean isFocusable() {89return false;90}9192public void setVisible(boolean b) {93}9495public void show() {96}9798public void hide() {99}100101public void setEnabled(boolean b) {102}103104public void enable() {105}106107public void disable() {108}109110public void paint(Graphics g) {111}112113public void repaint(long tm, int x, int y, int width, int height) {114}115116public void print(Graphics g) {117}118119public void setBounds(int x, int y, int width, int height, int op) {120}121122public void reshape(int x, int y, int width, int height) {123}124125public void coalescePaintEvent(PaintEvent e) {126}127128public boolean handleEvent(Event e) {129return false;130}131132public void handleEvent(java.awt.AWTEvent arg0) {133}134135public Dimension getPreferredSize() {136return new Dimension(1,1);137}138139public Dimension getMinimumSize() {140return new Dimension(1,1);141}142143public ColorModel getColorModel() {144return null;145}146147public Graphics getGraphics() {148return null;149}150151public GraphicsConfiguration getGraphicsConfiguration() {152return null;153}154155public FontMetrics getFontMetrics(Font font) {156return null;157}158159public void dispose() {160// no native code161}162163public void setForeground(Color c) {164}165166public void setBackground(Color c) {167}168169public void setFont(Font f) {170}171172public void updateCursorImmediately() {173}174175public void setCursor(Cursor cursor) {176}177178public boolean requestFocus179(Component lightweightChild, boolean temporary,180boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause) {181return false;182}183184public Image createImage(ImageProducer producer) {185return null;186}187188public Image createImage(int width, int height) {189return null;190}191192public boolean prepareImage(Image img, int w, int h, ImageObserver o) {193return false;194}195196public int checkImage(Image img, int w, int h, ImageObserver o) {197return 0;198}199200public Dimension preferredSize() {201return getPreferredSize();202}203204public Dimension minimumSize() {205return getMinimumSize();206}207208public Point getLocationOnScreen() {209return new Point(0,0);210}211212public Insets getInsets() {213return insets();214}215216public void beginValidate() {217}218219public void endValidate() {220}221222public Insets insets() {223return new Insets(0, 0, 0, 0);224}225226public boolean isPaintPending() {227return false;228}229230public boolean handlesWheelScrolling() {231return false;232}233234public VolatileImage createVolatileImage(int width, int height) {235return null;236}237238public void beginLayout() {239}240241public void endLayout() {242}243244public void createBuffers(int numBuffers, BufferCapabilities caps)245throws AWTException {246throw new AWTException(247"Page-flipping is not allowed on a lightweight component");248}249public Image getBackBuffer() {250throw new IllegalStateException(251"Page-flipping is not allowed on a lightweight component");252}253public void flip(int x1, int y1, int x2, int y2,254BufferCapabilities.FlipContents flipAction)255{256throw new IllegalStateException(257"Page-flipping is not allowed on a lightweight component");258}259public void destroyBuffers() {260}261262/**263* @see java.awt.peer.ComponentPeer#isReparentSupported264*/265public boolean isReparentSupported() {266return false;267}268269/**270* @see java.awt.peer.ComponentPeer#reparent271*/272public void reparent(ContainerPeer newNativeParent) {273throw new UnsupportedOperationException();274}275276public void layout() {277}278279public Rectangle getBounds() {280return new Rectangle(0, 0, 0, 0);281}282283284/**285* Applies the shape to the native component window.286* @since 1.7287*/288public void applyShape(Region shape) {289}290291/**292* Lowers this component at the bottom of the above HW peer. If the above parameter293* is null then the method places this component at the top of the Z-order.294*/295public void setZOrder(ComponentPeer above) {296}297298public boolean updateGraphicsData(GraphicsConfiguration gc) {299return false;300}301302public GraphicsConfiguration getAppropriateGraphicsConfiguration(303GraphicsConfiguration gc)304{305return gc;306}307}308309310