Home | History | Annotate | Download | only in awt
      1 /*
      2  *  Licensed to the Apache Software Foundation (ASF) under one or more
      3  *  contributor license agreements.  See the NOTICE file distributed with
      4  *  this work for additional information regarding copyright ownership.
      5  *  The ASF licenses this file to You under the Apache License, Version 2.0
      6  *  (the "License"); you may not use this file except in compliance with
      7  *  the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  */
     17 
     18 package java.awt;
     19 
     20 //import java.awt.dnd.DropTarget;
     21 import java.awt.event.ComponentEvent;
     22 import java.awt.event.ComponentListener;
     23 import java.awt.event.FocusEvent;
     24 import java.awt.event.FocusListener;
     25 import java.awt.event.HierarchyBoundsListener;
     26 import java.awt.event.HierarchyEvent;
     27 import java.awt.event.HierarchyListener;
     28 import java.awt.event.InputMethodEvent;
     29 import java.awt.event.InputMethodListener;
     30 import java.awt.event.InvocationEvent;
     31 import java.awt.event.KeyEvent;
     32 import java.awt.event.KeyListener;
     33 import java.awt.event.MouseEvent;
     34 import java.awt.event.MouseListener;
     35 import java.awt.event.MouseMotionListener;
     36 import java.awt.event.MouseWheelEvent;
     37 import java.awt.event.MouseWheelListener;
     38 import java.awt.event.PaintEvent;
     39 import java.awt.event.WindowEvent;
     40 import java.awt.im.InputContext;
     41 import java.awt.im.InputMethodRequests;
     42 import java.awt.image.BufferStrategy;
     43 import java.awt.image.BufferedImage;
     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.image.WritableRaster;
     49 import java.awt.peer.ComponentPeer;
     50 import java.beans.PropertyChangeListener;
     51 import java.beans.PropertyChangeSupport;
     52 import java.io.IOException;
     53 import java.io.ObjectInputStream;
     54 import java.io.PrintStream;
     55 import java.io.PrintWriter;
     56 import java.io.Serializable;
     57 import java.lang.reflect.Array;
     58 import java.lang.reflect.Method;
     59 import java.security.AccessController;
     60 import java.security.PrivilegedAction;
     61 import java.util.ArrayList;
     62 import java.util.Collection;
     63 import java.util.EventListener;
     64 import java.util.HashMap;
     65 import java.util.HashSet;
     66 import java.util.Hashtable;
     67 import java.util.Iterator;
     68 import java.util.LinkedList;
     69 import java.util.Locale;
     70 import java.util.Map;
     71 import java.util.Set;
     72 
     73 //???AWT
     74 //import javax.accessibility.Accessible;
     75 //import javax.accessibility.AccessibleComponent;
     76 //import javax.accessibility.AccessibleContext;
     77 //import javax.accessibility.AccessibleRole;
     78 //import javax.accessibility.AccessibleState;
     79 //import javax.accessibility.AccessibleStateSet;
     80 
     81 import org.apache.harmony.awt.ClipRegion; //import org.apache.harmony.awt.FieldsAccessor;
     82 import org.apache.harmony.awt.gl.MultiRectArea;
     83 import org.apache.harmony.awt.internal.nls.Messages;
     84 import org.apache.harmony.awt.state.State; //import org.apache.harmony.awt.text.TextFieldKit;
     85 //import org.apache.harmony.awt.text.TextKit;
     86 import org.apache.harmony.awt.wtk.NativeWindow;
     87 import org.apache.harmony.luni.util.NotImplementedException;
     88 
     89 /**
     90  * The abstract Component class specifies an object with a graphical
     91  * representation that can be displayed on the screen and that can interact with
     92  * the user (for example: scrollbars, buttons, checkboxes).
     93  *
     94  * @since Android 1.0
     95  */
     96 public abstract class Component implements ImageObserver, MenuContainer, Serializable {
     97 
     98     /**
     99      * The Constant serialVersionUID.
    100      */
    101     private static final long serialVersionUID = -7644114512714619750L;
    102 
    103     /**
    104      * The Constant TOP_ALIGNMENT indicates the top alignment of the component.
    105      */
    106     public static final float TOP_ALIGNMENT = 0.0f;
    107 
    108     /**
    109      * The Constant CENTER_ALIGNMENT indicates the center alignment of the
    110      * component.
    111      */
    112     public static final float CENTER_ALIGNMENT = 0.5f;
    113 
    114     /**
    115      * The Constant BOTTOM_ALIGNMENT indicates the bottom alignment of the
    116      * component.
    117      */
    118     public static final float BOTTOM_ALIGNMENT = 1.0f;
    119 
    120     /**
    121      * The Constant LEFT_ALIGNMENT indicates the left alignment of the
    122      * component.
    123      */
    124     public static final float LEFT_ALIGNMENT = 0.0f;
    125 
    126     /**
    127      * The Constant RIGHT_ALIGNMENT indicates the right alignment of the
    128      * component.
    129      */
    130     public static final float RIGHT_ALIGNMENT = 1.0f;
    131 
    132     /**
    133      * The Constant childClassesFlags.
    134      */
    135     private static final Hashtable<Class<?>, Boolean> childClassesFlags = new Hashtable<Class<?>, Boolean>();
    136 
    137     /**
    138      * The Constant peer.
    139      */
    140     private static final ComponentPeer peer = new ComponentPeer() {
    141     };
    142 
    143     /**
    144      * The Constant incrementalImageUpdate.
    145      */
    146     private static final boolean incrementalImageUpdate;
    147 
    148     /**
    149      * The toolkit.
    150      */
    151     final transient Toolkit toolkit = Toolkit.getDefaultToolkit();
    152 
    153     // ???AWT
    154     /*
    155      * protected abstract class AccessibleAWTComponent extends AccessibleContext
    156      * implements Serializable, AccessibleComponent { private static final long
    157      * serialVersionUID = 642321655757800191L; protected class
    158      * AccessibleAWTComponentHandler implements ComponentListener { protected
    159      * AccessibleAWTComponentHandler() { } public void
    160      * componentHidden(ComponentEvent e) { if (behaviour.isLightweight()) {
    161      * return; } firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
    162      * AccessibleState.VISIBLE, null); } public void
    163      * componentMoved(ComponentEvent e) { } public void
    164      * componentResized(ComponentEvent e) { } public void
    165      * componentShown(ComponentEvent e) { if (behaviour.isLightweight()) {
    166      * return; } firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
    167      * null, AccessibleState.VISIBLE); } } protected class
    168      * AccessibleAWTFocusHandler implements FocusListener { public void
    169      * focusGained(FocusEvent e) { if (behaviour.isLightweight()) { return; }
    170      * firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY, null,
    171      * AccessibleState.FOCUSED); } public void focusLost(FocusEvent e) { if
    172      * (behaviour.isLightweight()) { return; }
    173      * firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
    174      * AccessibleState.FOCUSED, null); } } protected ComponentListener
    175      * accessibleAWTComponentHandler; protected FocusListener
    176      * accessibleAWTFocusHandler;
    177      */
    178     /*
    179      * Number of registered property change listeners.
    180      */
    181     /*
    182      * int listenersCount; public void addFocusListener(FocusListener l) {
    183      * Component.this.addFocusListener(l); }
    184      * @Override public void addPropertyChangeListener(PropertyChangeListener
    185      * listener) { toolkit.lockAWT(); try {
    186      * super.addPropertyChangeListener(listener); listenersCount++; if
    187      * (accessibleAWTComponentHandler == null) { accessibleAWTComponentHandler =
    188      * new AccessibleAWTComponentHandler();
    189      * Component.this.addComponentListener(accessibleAWTComponentHandler); } if
    190      * (accessibleAWTFocusHandler == null) { accessibleAWTFocusHandler = new
    191      * AccessibleAWTFocusHandler();
    192      * Component.this.addFocusListener(accessibleAWTFocusHandler); } } finally {
    193      * toolkit.unlockAWT(); } } public boolean contains(Point p) {
    194      * toolkit.lockAWT(); try { return Component.this.contains(p); } finally {
    195      * toolkit.unlockAWT(); } } public Accessible getAccessibleAt(Point arg0) {
    196      * toolkit.lockAWT(); try { return null; } finally { toolkit.unlockAWT(); }
    197      * } public Color getBackground() { toolkit.lockAWT(); try { return
    198      * Component.this.getBackground(); } finally { toolkit.unlockAWT(); } }
    199      * public Rectangle getBounds() { toolkit.lockAWT(); try { return
    200      * Component.this.getBounds(); } finally { toolkit.unlockAWT(); } } public
    201      * Cursor getCursor() { toolkit.lockAWT(); try { return
    202      * Component.this.getCursor(); } finally { toolkit.unlockAWT(); } } public
    203      * Font getFont() { toolkit.lockAWT(); try { return
    204      * Component.this.getFont(); } finally { toolkit.unlockAWT(); } } public
    205      * FontMetrics getFontMetrics(Font f) { toolkit.lockAWT(); try { return
    206      * Component.this.getFontMetrics(f); } finally { toolkit.unlockAWT(); } }
    207      * public Color getForeground() { toolkit.lockAWT(); try { return
    208      * Component.this.getForeground(); } finally { toolkit.unlockAWT(); } }
    209      * public Point getLocation() { toolkit.lockAWT(); try { return
    210      * Component.this.getLocation(); } finally { toolkit.unlockAWT(); } } public
    211      * Point getLocationOnScreen() { toolkit.lockAWT(); try { return
    212      * Component.this.getLocationOnScreen(); } finally { toolkit.unlockAWT(); }
    213      * } public Dimension getSize() { toolkit.lockAWT(); try { return
    214      * Component.this.getSize(); } finally { toolkit.unlockAWT(); } } public
    215      * boolean isEnabled() { toolkit.lockAWT(); try { return
    216      * Component.this.isEnabled(); } finally { toolkit.unlockAWT(); } } public
    217      * boolean isFocusTraversable() { toolkit.lockAWT(); try { return
    218      * Component.this.isFocusTraversable(); } finally { toolkit.unlockAWT(); } }
    219      * public boolean isShowing() { toolkit.lockAWT(); try { return
    220      * Component.this.isShowing(); } finally { toolkit.unlockAWT(); } } public
    221      * boolean isVisible() { toolkit.lockAWT(); try { return
    222      * Component.this.isVisible(); } finally { toolkit.unlockAWT(); } } public
    223      * void removeFocusListener(FocusListener l) {
    224      * Component.this.removeFocusListener(l); }
    225      * @Override public void removePropertyChangeListener(PropertyChangeListener
    226      * listener) { toolkit.lockAWT(); try {
    227      * super.removePropertyChangeListener(listener); listenersCount--; if
    228      * (listenersCount > 0) { return; } // if there are no more listeners,
    229      * remove handlers:
    230      * Component.this.removeFocusListener(accessibleAWTFocusHandler);
    231      * Component.this.removeComponentListener(accessibleAWTComponentHandler);
    232      * accessibleAWTComponentHandler = null; accessibleAWTFocusHandler = null; }
    233      * finally { toolkit.unlockAWT(); } } public void requestFocus() {
    234      * toolkit.lockAWT(); try { Component.this.requestFocus(); } finally {
    235      * toolkit.unlockAWT(); } } public void setBackground(Color color) {
    236      * toolkit.lockAWT(); try { Component.this.setBackground(color); } finally {
    237      * toolkit.unlockAWT(); } } public void setBounds(Rectangle r) {
    238      * toolkit.lockAWT(); try { Component.this.setBounds(r); } finally {
    239      * toolkit.unlockAWT(); } } public void setCursor(Cursor cursor) {
    240      * toolkit.lockAWT(); try { Component.this.setCursor(cursor); } finally {
    241      * toolkit.unlockAWT(); } } public void setEnabled(boolean enabled) {
    242      * toolkit.lockAWT(); try { Component.this.setEnabled(enabled); } finally {
    243      * toolkit.unlockAWT(); } } public void setFont(Font f) { toolkit.lockAWT();
    244      * try { Component.this.setFont(f); } finally { toolkit.unlockAWT(); } }
    245      * public void setForeground(Color color) { toolkit.lockAWT(); try {
    246      * Component.this.setForeground(color); } finally { toolkit.unlockAWT(); } }
    247      * public void setLocation(Point p) { toolkit.lockAWT(); try {
    248      * Component.this.setLocation(p); } finally { toolkit.unlockAWT(); } }
    249      * public void setSize(Dimension size) { toolkit.lockAWT(); try {
    250      * Component.this.setSize(size); } finally { toolkit.unlockAWT(); } } public
    251      * void setVisible(boolean visible) { toolkit.lockAWT(); try {
    252      * Component.this.setVisible(visible); } finally { toolkit.unlockAWT(); } }
    253      * @Override public Accessible getAccessibleParent() { toolkit.lockAWT();
    254      * try { Accessible aParent = super.getAccessibleParent(); if (aParent !=
    255      * null) { return aParent; } Container parent = getParent(); return (parent
    256      * instanceof Accessible ? (Accessible) parent : null); } finally {
    257      * toolkit.unlockAWT(); } }
    258      * @Override public Accessible getAccessibleChild(int i) {
    259      * toolkit.lockAWT(); try { return null; } finally { toolkit.unlockAWT(); }
    260      * }
    261      * @Override public int getAccessibleChildrenCount() { toolkit.lockAWT();
    262      * try { return 0; } finally { toolkit.unlockAWT(); } }
    263      * @Override public AccessibleComponent getAccessibleComponent() { return
    264      * this; }
    265      * @Override public String getAccessibleDescription() { return
    266      * super.getAccessibleDescription(); // why override? }
    267      * @Override public int getAccessibleIndexInParent() { toolkit.lockAWT();
    268      * try { if (getAccessibleParent() == null) { return -1; } int count = 0;
    269      * Container parent = getParent(); for (int i = 0; i <
    270      * parent.getComponentCount(); i++) { Component aComp =
    271      * parent.getComponent(i); if (aComp instanceof Accessible) { if (aComp ==
    272      * Component.this) { return count; } ++count; } } return -1; } finally {
    273      * toolkit.unlockAWT(); } }
    274      * @Override public AccessibleRole getAccessibleRole() { toolkit.lockAWT();
    275      * try { return AccessibleRole.AWT_COMPONENT; } finally {
    276      * toolkit.unlockAWT(); } }
    277      * @Override public AccessibleStateSet getAccessibleStateSet() {
    278      * toolkit.lockAWT(); try { AccessibleStateSet set = new
    279      * AccessibleStateSet(); if (isEnabled()) {
    280      * set.add(AccessibleState.ENABLED); } if (isFocusable()) {
    281      * set.add(AccessibleState.FOCUSABLE); } if (hasFocus()) {
    282      * set.add(AccessibleState.FOCUSED); } if (isOpaque()) {
    283      * set.add(AccessibleState.OPAQUE); } if (isShowing()) {
    284      * set.add(AccessibleState.SHOWING); } if (isVisible()) {
    285      * set.add(AccessibleState.VISIBLE); } return set; } finally {
    286      * toolkit.unlockAWT(); } }
    287      * @Override public Locale getLocale() throws IllegalComponentStateException
    288      * { toolkit.lockAWT(); try { return Component.this.getLocale(); } finally {
    289      * toolkit.unlockAWT(); } } }
    290      */
    291     /**
    292      * The BltBufferStrategy class provides opportunity of blitting offscreen
    293      * surfaces to a component. For more information on blitting, see <a
    294      * href="http://en.wikipedia.org/wiki/Bit_blit">Bit blit</a>.
    295      *
    296      * @since Android 1.0
    297      */
    298     protected class BltBufferStrategy extends BufferStrategy {
    299 
    300         /**
    301          * The back buffers.
    302          */
    303         protected VolatileImage[] backBuffers;
    304 
    305         /**
    306          * The caps.
    307          */
    308         protected BufferCapabilities caps;
    309 
    310         /**
    311          * The width.
    312          */
    313         protected int width;
    314 
    315         /**
    316          * The height.
    317          */
    318         protected int height;
    319 
    320         /**
    321          * The validated contents.
    322          */
    323         protected boolean validatedContents;
    324 
    325         /**
    326          * Instantiates a new BltBufferStrategy buffer strategy.
    327          *
    328          * @param numBuffers
    329          *            the number of buffers.
    330          * @param caps
    331          *            the BufferCapabilities.
    332          * @throws NotImplementedException
    333          *             the not implemented exception.
    334          */
    335         protected BltBufferStrategy(int numBuffers, BufferCapabilities caps)
    336                 throws org.apache.harmony.luni.util.NotImplementedException {
    337             if (true) {
    338                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    339             }
    340         }
    341 
    342         /**
    343          * Returns true if the drawing buffer has been lost since the last call
    344          * to getDrawGraphics.
    345          *
    346          * @return true if the drawing buffer has been lost since the last call
    347          *         to getDrawGraphics, false otherwise.
    348          * @see java.awt.image.BufferStrategy#contentsLost()
    349          */
    350         @Override
    351         public boolean contentsLost() {
    352             if (true) {
    353                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    354             }
    355             return false;
    356         }
    357 
    358         /**
    359          * Returns true if the drawing buffer has been restored from a lost
    360          * state and reinitialized to the default background color.
    361          *
    362          * @return true if the drawing buffer has been restored from a lost
    363          *         state and reinitialized to the default background color,
    364          *         false otherwise.
    365          * @see java.awt.image.BufferStrategy#contentsRestored()
    366          */
    367         @Override
    368         public boolean contentsRestored() {
    369             if (true) {
    370                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    371             }
    372             return false;
    373         }
    374 
    375         /**
    376          * Creates the back buffers.
    377          *
    378          * @param numBuffers
    379          *            the number of buffers.
    380          */
    381         protected void createBackBuffers(int numBuffers) {
    382             if (true) {
    383                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    384             }
    385         }
    386 
    387         /**
    388          * Returns the BufferCapabilities of the buffer strategy.
    389          *
    390          * @return the BufferCapabilities.
    391          * @see java.awt.image.BufferStrategy#getCapabilities()
    392          */
    393         @Override
    394         public BufferCapabilities getCapabilities() {
    395             return (BufferCapabilities)caps.clone();
    396         }
    397 
    398         /**
    399          * Gets Graphics of current buffer strategy.
    400          *
    401          * @return the Graphics of current buffer strategy.
    402          * @see java.awt.image.BufferStrategy#getDrawGraphics()
    403          */
    404         @Override
    405         public Graphics getDrawGraphics() {
    406             if (true) {
    407                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    408             }
    409             return null;
    410         }
    411 
    412         /**
    413          * Revalidates the lost drawing buffer.
    414          */
    415         protected void revalidate() {
    416             if (true) {
    417                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    418             }
    419         }
    420 
    421         /**
    422          * Shows the next available buffer.
    423          *
    424          * @see java.awt.image.BufferStrategy#show()
    425          */
    426         @Override
    427         public void show() {
    428             if (true) {
    429                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    430             }
    431         }
    432     }
    433 
    434     /**
    435      * The FlipBufferStrategy class is for flipping buffers on a component.
    436      *
    437      * @since Android 1.0
    438      */
    439     protected class FlipBufferStrategy extends BufferStrategy {
    440 
    441         /**
    442          * The Buffer Capabilities.
    443          */
    444         protected BufferCapabilities caps;
    445 
    446         /**
    447          * The drawing buffer.
    448          */
    449         protected Image drawBuffer;
    450 
    451         /**
    452          * The drawing VolatileImage buffer.
    453          */
    454         protected VolatileImage drawVBuffer;
    455 
    456         /**
    457          * The number of buffers.
    458          */
    459         protected int numBuffers;
    460 
    461         /**
    462          * The validated contents indicates if the drawing buffer is restored
    463          * from lost state.
    464          */
    465         protected boolean validatedContents;
    466 
    467         /**
    468          * Instantiates a new flip buffer strategy.
    469          *
    470          * @param numBuffers
    471          *            the number of buffers.
    472          * @param caps
    473          *            the BufferCapabilities.
    474          * @throws AWTException
    475          *             if the capabilities supplied could not be supported or
    476          *             met.
    477          */
    478         protected FlipBufferStrategy(int numBuffers, BufferCapabilities caps) throws AWTException {
    479             // ???AWT
    480             /*
    481              * if (!(Component.this instanceof Window) && !(Component.this
    482              * instanceof Canvas)) { // awt.14B=Only Canvas or Window is allowed
    483              * throw new ClassCastException(Messages.getString("awt.14B"));
    484              * //$NON-NLS-1$ }
    485              */
    486             // TODO: throw new AWTException("Capabilities are not supported");
    487             this.numBuffers = numBuffers;
    488             this.caps = (BufferCapabilities)caps.clone();
    489         }
    490 
    491         /**
    492          * Returns true if the drawing buffer has been lost since the last call
    493          * to getDrawGraphics.
    494          *
    495          * @return true if the drawing buffer has been lost since the last call
    496          *         to getDrawGraphics, false otherwise.
    497          * @see java.awt.image.BufferStrategy#contentsLost()
    498          */
    499         @Override
    500         public boolean contentsLost() {
    501             if (true) {
    502                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    503             }
    504             return false;
    505         }
    506 
    507         /**
    508          * Returns true if the drawing buffer has been restored from a lost
    509          * state and reinitialized to the default background color.
    510          *
    511          * @return true if the drawing buffer has been restored from a lost
    512          *         state and reinitialized to the default background color,
    513          *         false otherwise.
    514          * @see java.awt.image.BufferStrategy#contentsRestored()
    515          */
    516         @Override
    517         public boolean contentsRestored() {
    518             if (true) {
    519                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    520             }
    521             return false;
    522         }
    523 
    524         /**
    525          * Creates flipping buffers with the specified buffer capabilities.
    526          *
    527          * @param numBuffers
    528          *            the number of buffers.
    529          * @param caps
    530          *            the BufferCapabilities.
    531          * @throws AWTException
    532          *             if the capabilities could not be supported or met.
    533          */
    534         protected void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException {
    535             if (numBuffers < 2) {
    536                 // awt.14C=Number of buffers must be greater than one
    537                 throw new IllegalArgumentException(Messages.getString("awt.14C")); //$NON-NLS-1$
    538             }
    539             if (!caps.isPageFlipping()) {
    540                 // awt.14D=Buffer capabilities should support flipping
    541                 throw new IllegalArgumentException(Messages.getString("awt.14D")); //$NON-NLS-1$
    542             }
    543             if (!Component.this.behaviour.isDisplayable()) {
    544                 // awt.14E=Component should be displayable
    545                 throw new IllegalStateException(Messages.getString("awt.14E")); //$NON-NLS-1$
    546             }
    547             // TODO: throw new AWTException("Capabilities are not supported");
    548             if (true) {
    549                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    550             }
    551         }
    552 
    553         /**
    554          * Destroy buffers.
    555          */
    556         protected void destroyBuffers() {
    557             if (true) {
    558                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    559             }
    560         }
    561 
    562         /**
    563          * Flips the contents of the back buffer to the front buffer.
    564          *
    565          * @param flipAction
    566          *            the flip action.
    567          */
    568         protected void flip(BufferCapabilities.FlipContents flipAction) {
    569             if (true) {
    570                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    571             }
    572         }
    573 
    574         /**
    575          * Gets the back buffer as Image.
    576          *
    577          * @return the back buffer as Image.
    578          */
    579         protected Image getBackBuffer() {
    580             if (true) {
    581                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    582             }
    583             return null;
    584         }
    585 
    586         /**
    587          * Returns the BufferCapabilities of the buffer strategy.
    588          *
    589          * @return the BufferCapabilities.
    590          * @see java.awt.image.BufferStrategy#getCapabilities()
    591          */
    592         @Override
    593         public BufferCapabilities getCapabilities() {
    594             return (BufferCapabilities)caps.clone();
    595         }
    596 
    597         /**
    598          * Gets Graphics of current buffer strategy.
    599          *
    600          * @return the Graphics of current buffer strategy.
    601          * @see java.awt.image.BufferStrategy#getDrawGraphics()
    602          */
    603         @Override
    604         public Graphics getDrawGraphics() {
    605             if (true) {
    606                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    607             }
    608             return null;
    609         }
    610 
    611         /**
    612          * Revalidates the lost drawing buffer.
    613          */
    614         protected void revalidate() {
    615             if (true) {
    616                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    617             }
    618         }
    619 
    620         /**
    621          * Shows the next available buffer.
    622          *
    623          * @see java.awt.image.BufferStrategy#show()
    624          */
    625         @Override
    626         public void show() {
    627             if (true) {
    628                 throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
    629             }
    630         }
    631     }
    632 
    633     /**
    634      * The internal component's state utilized by the visual theme.
    635      */
    636     class ComponentState implements State {
    637 
    638         /**
    639          * The default minimum size.
    640          */
    641         private Dimension defaultMinimumSize = new Dimension();
    642 
    643         /**
    644          * Checks if the component is enabled.
    645          *
    646          * @return true, if the component is enabled.
    647          */
    648         public boolean isEnabled() {
    649             return enabled;
    650         }
    651 
    652         /**
    653          * Checks if the component is visible.
    654          *
    655          * @return true, if the component is visible.
    656          */
    657         public boolean isVisible() {
    658             return visible;
    659         }
    660 
    661         /**
    662          * Checks if is focused.
    663          *
    664          * @return true, if is focused.
    665          */
    666         public boolean isFocused() {
    667             // ???AWT: return isFocusOwner();
    668             return false;
    669         }
    670 
    671         /**
    672          * Gets the font.
    673          *
    674          * @return the font.
    675          */
    676         public Font getFont() {
    677             return Component.this.getFont();
    678         }
    679 
    680         /**
    681          * Checks if the font has been set.
    682          *
    683          * @return true, if the font has been set.
    684          */
    685         public boolean isFontSet() {
    686             return font != null;
    687         }
    688 
    689         /**
    690          * Gets the background color.
    691          *
    692          * @return the background color.
    693          */
    694         public Color getBackground() {
    695             Color c = Component.this.getBackground();
    696             return (c != null) ? c : getDefaultBackground();
    697         }
    698 
    699         /**
    700          * Checks if the background is set.
    701          *
    702          * @return true, if the background is set.
    703          */
    704         public boolean isBackgroundSet() {
    705             return backColor != null;
    706         }
    707 
    708         /**
    709          * Gets the text color.
    710          *
    711          * @return the text color.
    712          */
    713         public Color getTextColor() {
    714             Color c = getForeground();
    715             return (c != null) ? c : getDefaultForeground();
    716         }
    717 
    718         /**
    719          * Checks if the text color is set.
    720          *
    721          * @return true, if the text color is set.
    722          */
    723         public boolean isTextColorSet() {
    724             return foreColor != null;
    725         }
    726 
    727         /**
    728          * Gets the font metrics.
    729          *
    730          * @return the font metrics.
    731          */
    732         @SuppressWarnings("deprecation")
    733         public FontMetrics getFontMetrics() {
    734             return toolkit.getFontMetrics(Component.this.getFont());
    735         }
    736 
    737         /**
    738          * Gets the bounding rectangle.
    739          *
    740          * @return the bounding rectangle.
    741          */
    742         public Rectangle getBounds() {
    743             return new Rectangle(x, y, w, h);
    744         }
    745 
    746         /**
    747          * Gets the size of the bounding rectangle.
    748          *
    749          * @return the size of the bounding rectangle.
    750          */
    751         public Dimension getSize() {
    752             return new Dimension(w, h);
    753         }
    754 
    755         /**
    756          * Gets the window id.
    757          *
    758          * @return the window id.
    759          */
    760         public long getWindowId() {
    761             NativeWindow win = getNativeWindow();
    762             return (win != null) ? win.getId() : 0;
    763         }
    764 
    765         /**
    766          * Gets the default minimum size.
    767          *
    768          * @return the default minimum size.
    769          */
    770         public Dimension getDefaultMinimumSize() {
    771             if (defaultMinimumSize == null) {
    772                 calculate();
    773             }
    774             return defaultMinimumSize;
    775         }
    776 
    777         /**
    778          * Sets the default minimum size.
    779          *
    780          * @param size
    781          *            the new default minimum size.
    782          */
    783         public void setDefaultMinimumSize(Dimension size) {
    784             defaultMinimumSize = size;
    785         }
    786 
    787         /**
    788          * Reset the default minimum size to null.
    789          */
    790         public void reset() {
    791             defaultMinimumSize = null;
    792         }
    793 
    794         /**
    795          * Calculate the default minimum size: to be overridden.
    796          */
    797         public void calculate() {
    798             // to be overridden
    799         }
    800     }
    801 
    802     // ???AWT: private transient AccessibleContext accessibleContext;
    803 
    804     /**
    805      * The behaviour.
    806      */
    807     final transient ComponentBehavior behaviour;
    808 
    809     // ???AWT: Container parent;
    810 
    811     /**
    812      * The name.
    813      */
    814     private String name;
    815 
    816     /**
    817      * The auto name.
    818      */
    819     private boolean autoName = true;
    820 
    821     /**
    822      * The font.
    823      */
    824     private Font font;
    825 
    826     /**
    827      * The back color.
    828      */
    829     private Color backColor;
    830 
    831     /**
    832      * The fore color.
    833      */
    834     private Color foreColor;
    835 
    836     /**
    837      * The deprecated event handler.
    838      */
    839     boolean deprecatedEventHandler = true;
    840 
    841     /**
    842      * The enabled events.
    843      */
    844     private long enabledEvents;
    845 
    846     /**
    847      * The enabled AWT events.
    848      */
    849     private long enabledAWTEvents;
    850 
    851     /**
    852      * The component listeners.
    853      */
    854     private final AWTListenerList<ComponentListener> componentListeners = new AWTListenerList<ComponentListener>(
    855             this);
    856 
    857     /**
    858      * The focus listeners.
    859      */
    860     private final AWTListenerList<FocusListener> focusListeners = new AWTListenerList<FocusListener>(
    861             this);
    862 
    863     /**
    864      * The hierarchy listeners.
    865      */
    866     private final AWTListenerList<HierarchyListener> hierarchyListeners = new AWTListenerList<HierarchyListener>(
    867             this);
    868 
    869     /**
    870      * The hierarchy bounds listeners.
    871      */
    872     private final AWTListenerList<HierarchyBoundsListener> hierarchyBoundsListeners = new AWTListenerList<HierarchyBoundsListener>(
    873             this);
    874 
    875     /**
    876      * The key listeners.
    877      */
    878     private final AWTListenerList<KeyListener> keyListeners = new AWTListenerList<KeyListener>(this);
    879 
    880     /**
    881      * The mouse listeners.
    882      */
    883     private final AWTListenerList<MouseListener> mouseListeners = new AWTListenerList<MouseListener>(
    884             this);
    885 
    886     /**
    887      * The mouse motion listeners.
    888      */
    889     private final AWTListenerList<MouseMotionListener> mouseMotionListeners = new AWTListenerList<MouseMotionListener>(
    890             this);
    891 
    892     /**
    893      * The mouse wheel listeners.
    894      */
    895     private final AWTListenerList<MouseWheelListener> mouseWheelListeners = new AWTListenerList<MouseWheelListener>(
    896             this);
    897 
    898     /**
    899      * The input method listeners.
    900      */
    901     private final AWTListenerList<InputMethodListener> inputMethodListeners = new AWTListenerList<InputMethodListener>(
    902             this);
    903 
    904     /**
    905      * The x.
    906      */
    907     int x;
    908 
    909     /**
    910      * The y.
    911      */
    912     int y;
    913 
    914     /**
    915      * The w.
    916      */
    917     int w;
    918 
    919     /**
    920      * The h.
    921      */
    922     int h;
    923 
    924     /**
    925      * The maximum size.
    926      */
    927     private Dimension maximumSize;
    928 
    929     /**
    930      * The minimum size.
    931      */
    932     private Dimension minimumSize;
    933 
    934     /**
    935      * The preferred size.
    936      */
    937     private Dimension preferredSize;
    938 
    939     /**
    940      * The bounds mask param.
    941      */
    942     private int boundsMaskParam;
    943 
    944     /**
    945      * The ignore repaint.
    946      */
    947     private boolean ignoreRepaint;
    948 
    949     /**
    950      * The enabled.
    951      */
    952     private boolean enabled = true;
    953 
    954     /**
    955      * The input methods enabled.
    956      */
    957     private boolean inputMethodsEnabled = true;
    958 
    959     /**
    960      * The dispatch to im.
    961      */
    962     transient boolean dispatchToIM = true;
    963 
    964     /**
    965      * The focusable.
    966      */
    967     private boolean focusable = true; // By default, all Components return
    968 
    969     // true from isFocusable() method
    970     /**
    971      * The visible.
    972      */
    973     boolean visible = true;
    974 
    975     /**
    976      * The called set focusable.
    977      */
    978     private boolean calledSetFocusable;
    979 
    980     /**
    981      * The overridden is focusable.
    982      */
    983     private boolean overridenIsFocusable = true;
    984 
    985     /**
    986      * The focus traversal keys enabled.
    987      */
    988     private boolean focusTraversalKeysEnabled = true;
    989 
    990     /**
    991      * Possible keys are: FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,
    992      * UP_CYCLE_TRAVERSAL_KEYS.
    993      */
    994     private final Map<Integer, Set<? extends AWTKeyStroke>> traversalKeys = new HashMap<Integer, Set<? extends AWTKeyStroke>>();
    995 
    996     /**
    997      * The traversal i ds.
    998      */
    999     int[] traversalIDs;
   1000 
   1001     /**
   1002      * The locale.
   1003      */
   1004     private Locale locale;
   1005 
   1006     /**
   1007      * The orientation.
   1008      */
   1009     private ComponentOrientation orientation;
   1010 
   1011     /**
   1012      * The property change support.
   1013      */
   1014     private PropertyChangeSupport propertyChangeSupport;
   1015 
   1016     // ???AWT: private ArrayList<PopupMenu> popups;
   1017 
   1018     /**
   1019      * The coalescer.
   1020      */
   1021     private boolean coalescer;
   1022 
   1023     /**
   1024      * The events table.
   1025      */
   1026     private Hashtable<Integer, LinkedList<AWTEvent>> eventsTable;
   1027 
   1028     /**
   1029      * Cashed reference used during EventQueue.postEvent()
   1030      */
   1031     private LinkedList<AWTEvent> eventsList;
   1032 
   1033     /**
   1034      * The hierarchy changing counter.
   1035      */
   1036     private int hierarchyChangingCounter;
   1037 
   1038     /**
   1039      * The was showing.
   1040      */
   1041     private boolean wasShowing;
   1042 
   1043     /**
   1044      * The was displayable.
   1045      */
   1046     private boolean wasDisplayable;
   1047 
   1048     /**
   1049      * The cursor.
   1050      */
   1051     Cursor cursor;
   1052 
   1053     // ???AWT: DropTarget dropTarget;
   1054 
   1055     /**
   1056      * The mouse exited expected.
   1057      */
   1058     private boolean mouseExitedExpected;
   1059 
   1060     /**
   1061      * The repaint region.
   1062      */
   1063     transient MultiRectArea repaintRegion;
   1064 
   1065     // ???AWT: transient RedrawManager redrawManager;
   1066     /**
   1067      * The redraw manager.
   1068      */
   1069     transient Object redrawManager;
   1070 
   1071     /**
   1072      * The valid.
   1073      */
   1074     private boolean valid;
   1075 
   1076     /**
   1077      * The updated images.
   1078      */
   1079     private HashMap<Image, ImageParameters> updatedImages;
   1080 
   1081     /**
   1082      * The lock object for private component's data which don't affect the
   1083      * component hierarchy.
   1084      */
   1085     private class ComponentLock {
   1086     }
   1087 
   1088     /**
   1089      * The component lock.
   1090      */
   1091     private final transient Object componentLock = new ComponentLock();
   1092     static {
   1093         PrivilegedAction<String[]> action = new PrivilegedAction<String[]>() {
   1094             public String[] run() {
   1095                 String properties[] = new String[2];
   1096                 properties[0] = System.getProperty("awt.image.redrawrate", "100"); //$NON-NLS-1$ //$NON-NLS-2$
   1097                 properties[1] = System.getProperty("awt.image.incrementaldraw", "true"); //$NON-NLS-1$ //$NON-NLS-2$
   1098                 return properties;
   1099             }
   1100         };
   1101         String properties[] = AccessController.doPrivileged(action);
   1102         // FIXME: rate is never used, can this code and the get property above
   1103         // be removed?
   1104         // int rate;
   1105         //
   1106         // try {
   1107         // rate = Integer.decode(properties[0]).intValue();
   1108         // } catch (NumberFormatException e) {
   1109         // rate = 100;
   1110         // }
   1111         incrementalImageUpdate = properties[1].equals("true"); //$NON-NLS-1$
   1112     }
   1113 
   1114     /**
   1115      * Instantiates a new component.
   1116      */
   1117     protected Component() {
   1118         toolkit.lockAWT();
   1119         try {
   1120             orientation = ComponentOrientation.UNKNOWN;
   1121             redrawManager = null;
   1122             // ???AWT
   1123             /*
   1124              * traversalIDs = this instanceof Container ?
   1125              * KeyboardFocusManager.contTraversalIDs :
   1126              * KeyboardFocusManager.compTraversalIDs; for (int element :
   1127              * traversalIDs) { traversalKeys.put(new Integer(element), null); }
   1128              * behaviour = createBehavior();
   1129              */
   1130             behaviour = null;
   1131 
   1132             deriveCoalescerFlag();
   1133         } finally {
   1134             toolkit.unlockAWT();
   1135         }
   1136     }
   1137 
   1138     /**
   1139      * Determine that the class inherited from Component declares the method
   1140      * coalesceEvents(), and put the results to the childClassesFlags map.
   1141      */
   1142     private void deriveCoalescerFlag() {
   1143         Class<?> thisClass = getClass();
   1144         boolean flag = true;
   1145         synchronized (childClassesFlags) {
   1146             Boolean flagWrapper = childClassesFlags.get(thisClass);
   1147             if (flagWrapper == null) {
   1148                 Method coalesceMethod = null;
   1149                 for (Class<?> c = thisClass; c != Component.class; c = c.getSuperclass()) {
   1150                     try {
   1151                         coalesceMethod = c.getDeclaredMethod("coalesceEvents", new Class[] { //$NON-NLS-1$
   1152                                         Class.forName("java.awt.AWTEvent"), //$NON-NLS-1$
   1153                                         Class.forName("java.awt.AWTEvent")}); //$NON-NLS-1$
   1154                     } catch (Exception e) {
   1155                     }
   1156                     if (coalesceMethod != null) {
   1157                         break;
   1158                     }
   1159                 }
   1160                 flag = (coalesceMethod != null);
   1161                 childClassesFlags.put(thisClass, Boolean.valueOf(flag));
   1162             } else {
   1163                 flag = flagWrapper.booleanValue();
   1164             }
   1165         }
   1166         coalescer = flag;
   1167         if (flag) {
   1168             eventsTable = new Hashtable<Integer, LinkedList<AWTEvent>>();
   1169         } else {
   1170             eventsTable = null;
   1171         }
   1172     }
   1173 
   1174     /**
   1175      * Sets the name of the Component.
   1176      *
   1177      * @param name
   1178      *            the new name of the Component.
   1179      */
   1180     public void setName(String name) {
   1181         String oldName;
   1182         toolkit.lockAWT();
   1183         try {
   1184             autoName = false;
   1185             oldName = this.name;
   1186             this.name = name;
   1187         } finally {
   1188             toolkit.unlockAWT();
   1189         }
   1190         firePropertyChange("name", oldName, name); //$NON-NLS-1$
   1191     }
   1192 
   1193     /**
   1194      * Gets the name of this Component.
   1195      *
   1196      * @return the name of this Component.
   1197      */
   1198     public String getName() {
   1199         toolkit.lockAWT();
   1200         try {
   1201             if ((name == null) && autoName) {
   1202                 name = autoName();
   1203             }
   1204             return name;
   1205         } finally {
   1206             toolkit.unlockAWT();
   1207         }
   1208     }
   1209 
   1210     /**
   1211      * Auto name.
   1212      *
   1213      * @return the string.
   1214      */
   1215     String autoName() {
   1216         String name = getClass().getName();
   1217         if (name.indexOf("$") != -1) { //$NON-NLS-1$
   1218             return null;
   1219         }
   1220         // ???AWT
   1221         // int number = toolkit.autoNumber.nextComponent++;
   1222         int number = 0;
   1223         name = name.substring(name.lastIndexOf(".") + 1) + Integer.toString(number); //$NON-NLS-1$
   1224         return name;
   1225     }
   1226 
   1227     /**
   1228      * Returns the string representation of the Component.
   1229      *
   1230      * @return the string representation of the Component.
   1231      */
   1232     @Override
   1233     public String toString() {
   1234         /*
   1235          * The format is based on 1.5 release behavior which can be revealed by
   1236          * the following code: Component c = new Component(){};
   1237          * c.setVisible(false); System.out.println(c);
   1238          */
   1239         toolkit.lockAWT();
   1240         try {
   1241             return getClass().getName() + "[" + paramString() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
   1242         } finally {
   1243             toolkit.unlockAWT();
   1244         }
   1245     }
   1246 
   1247     // ???AWT
   1248     /*
   1249      * public void add(PopupMenu popup) { toolkit.lockAWT(); try { if
   1250      * (popup.getParent() == this) { return; } if (popups == null) { popups =
   1251      * new ArrayList<PopupMenu>(); } popup.setParent(this); popups.add(popup); }
   1252      * finally { toolkit.unlockAWT(); } }
   1253      */
   1254 
   1255     /**
   1256      * Returns true, if the component contains the specified Point.
   1257      *
   1258      * @param p
   1259      *            the Point.
   1260      * @return true, if the component contains the specified Point, false
   1261      *         otherwise.
   1262      */
   1263     public boolean contains(Point p) {
   1264         toolkit.lockAWT();
   1265         try {
   1266             return contains(p.x, p.y);
   1267         } finally {
   1268             toolkit.unlockAWT();
   1269         }
   1270     }
   1271 
   1272     /**
   1273      * Returns true, if the component contains the point with the specified
   1274      * coordinates.
   1275      *
   1276      * @param x
   1277      *            the x coordinate.
   1278      * @param y
   1279      *            the y coordinate.
   1280      * @return true, if the component contains the point with the specified
   1281      *         coordinates, false otherwise.
   1282      */
   1283     public boolean contains(int x, int y) {
   1284         toolkit.lockAWT();
   1285         try {
   1286             return inside(x, y);
   1287         } finally {
   1288             toolkit.unlockAWT();
   1289         }
   1290     }
   1291 
   1292     /**
   1293      * Deprecated: replaced by replaced by getSize() method.
   1294      *
   1295      * @return the dimension.
   1296      * @deprecated Replaced by getSize() method.
   1297      */
   1298     @Deprecated
   1299     public Dimension size() {
   1300         toolkit.lockAWT();
   1301         try {
   1302             return new Dimension(w, h);
   1303         } finally {
   1304             toolkit.unlockAWT();
   1305         }
   1306     }
   1307 
   1308     // ???AWT
   1309     /*
   1310      * public Container getParent() { toolkit.lockAWT(); try { return parent; }
   1311      * finally { toolkit.unlockAWT(); } }
   1312      */
   1313 
   1314     /**
   1315      * List.
   1316      *
   1317      * @param out
   1318      *            the out.
   1319      * @param indent
   1320      *            the indent
   1321      * @return the nearest heavyweight ancestor in hierarchy or
   1322      *         <code>null</code> if not found.
   1323      */
   1324     // ???AWT
   1325     /*
   1326      * Component getHWAncestor() { return (parent != null ?
   1327      * parent.getHWSurface() : null); }
   1328      */
   1329 
   1330     /**
   1331      * @return heavyweight component that is equal to or is a nearest
   1332      *         heavyweight container of the current component, or
   1333      *         <code>null</code> if not found.
   1334      */
   1335     // ???AWT
   1336     /*
   1337      * Component getHWSurface() { Component parent; for (parent = this; (parent
   1338      * != null) && (parent.isLightweight()); parent = parent .getParent()) { ; }
   1339      * return parent; } Window getWindowAncestor() { Component par; for (par =
   1340      * this; par != null && !(par instanceof Window); par = par.getParent()) { ;
   1341      * } return (Window) par; }
   1342      */
   1343 
   1344     /**
   1345      * To be called by container
   1346      */
   1347     // ???AWT
   1348     /*
   1349      * void setParent(Container parent) { this.parent = parent;
   1350      * setRedrawManager(); } void setRedrawManager() { redrawManager =
   1351      * getRedrawManager(); } public void remove(MenuComponent menu) {
   1352      * toolkit.lockAWT(); try { if (menu.getParent() == this) {
   1353      * menu.setParent(null); popups.remove(menu); } } finally {
   1354      * toolkit.unlockAWT(); } }
   1355      */
   1356     /**
   1357      * Prints a list of this component with the specified number of leading
   1358      * whitespace characters to the specified PrintStream.
   1359      *
   1360      * @param out
   1361      *            the output PrintStream object.
   1362      * @param indent
   1363      *            how many leading whitespace characters to prepend.
   1364      */
   1365     public void list(PrintStream out, int indent) {
   1366         toolkit.lockAWT();
   1367         try {
   1368             out.println(getIndentStr(indent) + this);
   1369         } finally {
   1370             toolkit.unlockAWT();
   1371         }
   1372     }
   1373 
   1374     /**
   1375      * Prints a list of this component to the specified PrintWriter.
   1376      *
   1377      * @param out
   1378      *            the output PrintWriter object.
   1379      */
   1380     public void list(PrintWriter out) {
   1381         toolkit.lockAWT();
   1382         try {
   1383             list(out, 1);
   1384         } finally {
   1385             toolkit.unlockAWT();
   1386         }
   1387     }
   1388 
   1389     /**
   1390      * Prints a list of this component with the specified number of leading
   1391      * whitespace characters to the specified PrintWriter.
   1392      *
   1393      * @param out
   1394      *            the output PrintWriter object.
   1395      * @param indent
   1396      *            how many leading whitespace characters to prepend.
   1397      */
   1398     public void list(PrintWriter out, int indent) {
   1399         toolkit.lockAWT();
   1400         try {
   1401             out.println(getIndentStr(indent) + this);
   1402         } finally {
   1403             toolkit.unlockAWT();
   1404         }
   1405     }
   1406 
   1407     /**
   1408      * Gets a string composed of the desired number of whitespace characters.
   1409      *
   1410      * @param indent
   1411      *            the length of the String to return.
   1412      * @return the string composed of the desired number of whitespace
   1413      *         characters.
   1414      */
   1415     String getIndentStr(int indent) {
   1416         char[] ind = new char[indent];
   1417         for (int i = 0; i < indent; ind[i++] = ' ') {
   1418             ;
   1419         }
   1420         return new String(ind);
   1421     }
   1422 
   1423     /**
   1424      * Prints a list of this component to the specified PrintStream.
   1425      *
   1426      * @param out
   1427      *            the output PrintStream object.
   1428      */
   1429     public void list(PrintStream out) {
   1430         toolkit.lockAWT();
   1431         try {
   1432             // default indent = 1
   1433             list(out, 1);
   1434         } finally {
   1435             toolkit.unlockAWT();
   1436         }
   1437     }
   1438 
   1439     /**
   1440      * Prints a list of this component to the standard system output stream.
   1441      */
   1442     public void list() {
   1443         toolkit.lockAWT();
   1444         try {
   1445             list(System.out);
   1446         } finally {
   1447             toolkit.unlockAWT();
   1448         }
   1449     }
   1450 
   1451     /**
   1452      * Prints this component.
   1453      *
   1454      * @param g
   1455      *            the Graphics to be used for painting.
   1456      */
   1457     public void print(Graphics g) {
   1458         toolkit.lockAWT();
   1459         try {
   1460             paint(g);
   1461         } finally {
   1462             toolkit.unlockAWT();
   1463         }
   1464     }
   1465 
   1466     /**
   1467      * Prints the component and all of its subcomponents.
   1468      *
   1469      * @param g
   1470      *            the Graphics to be used for painting.
   1471      */
   1472     public void printAll(Graphics g) {
   1473         toolkit.lockAWT();
   1474         try {
   1475             paintAll(g);
   1476         } finally {
   1477             toolkit.unlockAWT();
   1478         }
   1479     }
   1480 
   1481     /**
   1482      * Sets the size of the Component specified by width and height parameters.
   1483      *
   1484      * @param width
   1485      *            the width of the Component.
   1486      * @param height
   1487      *            the height of the Component.
   1488      */
   1489     public void setSize(int width, int height) {
   1490         toolkit.lockAWT();
   1491         try {
   1492             resize(width, height);
   1493         } finally {
   1494             toolkit.unlockAWT();
   1495         }
   1496     }
   1497 
   1498     /**
   1499      * Sets the size of the Component specified by Dimension object.
   1500      *
   1501      * @param d
   1502      *            the new size of the Component.
   1503      */
   1504     public void setSize(Dimension d) {
   1505         toolkit.lockAWT();
   1506         try {
   1507             resize(d);
   1508         } finally {
   1509             toolkit.unlockAWT();
   1510         }
   1511     }
   1512 
   1513     /**
   1514      * Deprecated: replaced by setSize(int, int) method.
   1515      *
   1516      * @param width
   1517      *            the width.
   1518      * @param height
   1519      *            the height.
   1520      * @deprecated Replaced by setSize(int, int) method.
   1521      */
   1522     @Deprecated
   1523     public void resize(int width, int height) {
   1524         toolkit.lockAWT();
   1525         try {
   1526             boundsMaskParam = NativeWindow.BOUNDS_NOMOVE;
   1527             setBounds(x, y, width, height);
   1528         } finally {
   1529             toolkit.unlockAWT();
   1530         }
   1531     }
   1532 
   1533     /**
   1534      * Deprecated: replaced by setSize(int, int) method.
   1535      *
   1536      * @param size
   1537      *            the size.
   1538      * @deprecated Replaced by setSize(int, int) method.
   1539      */
   1540     @Deprecated
   1541     public void resize(Dimension size) {
   1542         toolkit.lockAWT();
   1543         try {
   1544             setSize(size.width, size.height);
   1545         } finally {
   1546             toolkit.unlockAWT();
   1547         }
   1548     }
   1549 
   1550     /**
   1551      * Checks whether or not this component is completely opaque.
   1552      *
   1553      * @return true, if this component is completely opaque, false by default.
   1554      */
   1555     public boolean isOpaque() {
   1556         toolkit.lockAWT();
   1557         try {
   1558             return behaviour.isOpaque();
   1559         } finally {
   1560             toolkit.unlockAWT();
   1561         }
   1562     }
   1563 
   1564     /**
   1565      * Disables.
   1566      *
   1567      * @deprecated Replaced by setEnabled(boolean) method.
   1568      */
   1569     @Deprecated
   1570     public void disable() {
   1571         toolkit.lockAWT();
   1572         try {
   1573             setEnabledImpl(false);
   1574         } finally {
   1575             toolkit.unlockAWT();
   1576         }
   1577         // ???AWT: fireAccessibleStateChange(AccessibleState.ENABLED, false);
   1578     }
   1579 
   1580     /**
   1581      * Enables this component.
   1582      *
   1583      * @deprecated Replaced by setEnabled(boolean) method.
   1584      */
   1585     @Deprecated
   1586     public void enable() {
   1587         toolkit.lockAWT();
   1588         try {
   1589             setEnabledImpl(true);
   1590         } finally {
   1591             toolkit.unlockAWT();
   1592         }
   1593         // ???AWT: fireAccessibleStateChange(AccessibleState.ENABLED, true);
   1594     }
   1595 
   1596     /**
   1597      * Enables or disable this component.
   1598      *
   1599      * @param b
   1600      *            the boolean parameter.
   1601      * @deprecated Replaced by setEnabled(boolean) method.
   1602      */
   1603     @Deprecated
   1604     public void enable(boolean b) {
   1605         toolkit.lockAWT();
   1606         try {
   1607             if (b) {
   1608                 enable();
   1609             } else {
   1610                 disable();
   1611             }
   1612         } finally {
   1613             toolkit.unlockAWT();
   1614         }
   1615     }
   1616 
   1617     /**
   1618      * Stores the location of this component to the specified Point object;
   1619      * returns the point of the component's top-left corner.
   1620      *
   1621      * @param rv
   1622      *            the Point object where the component's top-left corner
   1623      *            position will be stored.
   1624      * @return the Point which specifies the component's top-left corner.
   1625      */
   1626     public Point getLocation(Point rv) {
   1627         toolkit.lockAWT();
   1628         try {
   1629             if (rv == null) {
   1630                 rv = new Point();
   1631             }
   1632             rv.setLocation(getX(), getY());
   1633             return rv;
   1634         } finally {
   1635             toolkit.unlockAWT();
   1636         }
   1637     }
   1638 
   1639     /**
   1640      * Gets the location of this component on the form; returns the point of the
   1641      * component's top-left corner.
   1642      *
   1643      * @return the Point which specifies the component's top-left corner.
   1644      */
   1645     public Point getLocation() {
   1646         toolkit.lockAWT();
   1647         try {
   1648             return location();
   1649         } finally {
   1650             toolkit.unlockAWT();
   1651         }
   1652     }
   1653 
   1654     /**
   1655      * Gets the size of this Component.
   1656      *
   1657      * @return the size of this Component.
   1658      */
   1659     public Dimension getSize() {
   1660         toolkit.lockAWT();
   1661         try {
   1662             return size();
   1663         } finally {
   1664             toolkit.unlockAWT();
   1665         }
   1666     }
   1667 
   1668     /**
   1669      * Stores the size of this Component to the specified Dimension object.
   1670      *
   1671      * @param rv
   1672      *            the Dimension object where the size of the Component will be
   1673      *            stored.
   1674      * @return the Dimension of this Component.
   1675      */
   1676     public Dimension getSize(Dimension rv) {
   1677         toolkit.lockAWT();
   1678         try {
   1679             if (rv == null) {
   1680                 rv = new Dimension();
   1681             }
   1682             rv.setSize(getWidth(), getHeight());
   1683             return rv;
   1684         } finally {
   1685             toolkit.unlockAWT();
   1686         }
   1687     }
   1688 
   1689     /**
   1690      * Checks whether or not this Component is valid. A component is valid if it
   1691      * is correctly sized and positioned within its parent container and all its
   1692      * children are also valid.
   1693      *
   1694      * @return true, if the Component is valid, false otherwise.
   1695      */
   1696     public boolean isValid() {
   1697         toolkit.lockAWT();
   1698         try {
   1699             return valid && behaviour.isDisplayable();
   1700         } finally {
   1701             toolkit.unlockAWT();
   1702         }
   1703     }
   1704 
   1705     /**
   1706      * Deprecated: replaced by getComponentAt(int, int) method.
   1707      *
   1708      * @return the Point.
   1709      * @deprecated Replaced by getComponentAt(int, int) method.
   1710      */
   1711     @Deprecated
   1712     public Point location() {
   1713         toolkit.lockAWT();
   1714         try {
   1715             return new Point(x, y);
   1716         } finally {
   1717             toolkit.unlockAWT();
   1718         }
   1719     }
   1720 
   1721     /**
   1722      * Connects this Component to a native screen resource and makes it
   1723      * displayable. This method not be called directly by user applications.
   1724      */
   1725     public void addNotify() {
   1726         toolkit.lockAWT();
   1727         try {
   1728             prepare4HierarchyChange();
   1729             behaviour.addNotify();
   1730             // ???AWT
   1731             // finishHierarchyChange(this, parent, 0);
   1732             // if (dropTarget != null) {
   1733             // dropTarget.addNotify(peer);
   1734             // }
   1735         } finally {
   1736             toolkit.unlockAWT();
   1737         }
   1738     }
   1739 
   1740     /**
   1741      * Map to display.
   1742      *
   1743      * @param b
   1744      *            the b.
   1745      */
   1746     void mapToDisplay(boolean b) {
   1747         // ???AWT
   1748         /*
   1749          * if (b && !isDisplayable()) { if ((this instanceof Window) || ((parent
   1750          * != null) && parent.isDisplayable())) { addNotify(); } } else if (!b
   1751          * && isDisplayable()) { removeNotify(); }
   1752          */
   1753     }
   1754 
   1755     /**
   1756      * Gets the toolkit.
   1757      *
   1758      * @return accessible context specific for particular component.
   1759      */
   1760     // ???AWT
   1761     /*
   1762      * AccessibleContext createAccessibleContext() { return null; } public
   1763      * AccessibleContext getAccessibleContext() { toolkit.lockAWT(); try { if
   1764      * (accessibleContext == null) { accessibleContext =
   1765      * createAccessibleContext(); } return accessibleContext; } finally {
   1766      * toolkit.unlockAWT(); } }
   1767      */
   1768 
   1769     /**
   1770      * Gets Toolkit for the current Component.
   1771      *
   1772      * @return the Toolkit of this Component.
   1773      */
   1774     public Toolkit getToolkit() {
   1775         return toolkit;
   1776     }
   1777 
   1778     /**
   1779      * Gets this component's locking object for AWT component tree and layout
   1780      * operations.
   1781      *
   1782      * @return the tree locking object.
   1783      */
   1784     public final Object getTreeLock() {
   1785         return toolkit.awtTreeLock;
   1786     }
   1787 
   1788     /**
   1789      * Handles the event. Use ActionListener instead of this.
   1790      *
   1791      * @param evt
   1792      *            the Event.
   1793      * @param what
   1794      *            the event's key.
   1795      * @return true, if successful.
   1796      * @deprecated Use ActionListener class for registering event listener.
   1797      */
   1798     @Deprecated
   1799     public boolean action(Event evt, Object what) {
   1800         // to be overridden: do nothing,
   1801         // just return false to propagate event up to the parent container
   1802         return false;
   1803     }
   1804 
   1805     /**
   1806      * Gets the property change support.
   1807      *
   1808      * @return the property change support.
   1809      */
   1810     private PropertyChangeSupport getPropertyChangeSupport() {
   1811         synchronized (componentLock) {
   1812             if (propertyChangeSupport == null) {
   1813                 propertyChangeSupport = new PropertyChangeSupport(this);
   1814             }
   1815             return propertyChangeSupport;
   1816         }
   1817     }
   1818 
   1819     // ???AWT
   1820     /*
   1821      * public void addPropertyChangeListener(PropertyChangeListener listener) {
   1822      * getPropertyChangeSupport().addPropertyChangeListener(listener); } public
   1823      * void addPropertyChangeListener(String propertyName,
   1824      * PropertyChangeListener listener) {
   1825      * getPropertyChangeSupport().addPropertyChangeListener(propertyName,
   1826      * listener); } public void applyComponentOrientation(ComponentOrientation
   1827      * orientation) { toolkit.lockAWT(); try {
   1828      * setComponentOrientation(orientation); } finally { toolkit.unlockAWT(); }
   1829      * }
   1830      */
   1831 
   1832     /**
   1833      * Returns true if the set of focus traversal keys for the given focus
   1834      * traversal operation has been explicitly defined for this Component.
   1835      *
   1836      * @param id
   1837      *            the ID of traversal key.
   1838      * @return true, if the set of focus traversal keys for the given focus.
   1839      *         traversal operation has been explicitly defined for this
   1840      *         Component, false otherwise.
   1841      */
   1842     public boolean areFocusTraversalKeysSet(int id) {
   1843         toolkit.lockAWT();
   1844         try {
   1845             Integer Id = new Integer(id);
   1846             if (traversalKeys.containsKey(Id)) {
   1847                 return traversalKeys.get(Id) != null;
   1848             }
   1849             // awt.14F=invalid focus traversal key identifier
   1850             throw new IllegalArgumentException(Messages.getString("awt.14F")); //$NON-NLS-1$
   1851         } finally {
   1852             toolkit.unlockAWT();
   1853         }
   1854     }
   1855 
   1856     /**
   1857      * Gets the bounds of the Component.
   1858      *
   1859      * @return the rectangle bounds of the Component.
   1860      * @deprecated Use getBounds() methood.
   1861      */
   1862     @Deprecated
   1863     public Rectangle bounds() {
   1864         toolkit.lockAWT();
   1865         try {
   1866             return new Rectangle(x, y, w, h);
   1867         } finally {
   1868             toolkit.unlockAWT();
   1869         }
   1870     }
   1871 
   1872     /**
   1873      * Returns the construction status of a specified image with the specified
   1874      * width and height that is being created.
   1875      *
   1876      * @param image
   1877      *            the image to be checked.
   1878      * @param width
   1879      *            the width of scaled image which status is being checked, or
   1880      *            -1.
   1881      * @param height
   1882      *            the height of scaled image which status is being checked, or
   1883      *            -1.
   1884      * @param observer
   1885      *            the ImageObserver object to be notified while the image is
   1886      *            being prepared.
   1887      * @return the ImageObserver flags of the current state of the image data.
   1888      */
   1889     public int checkImage(Image image, int width, int height, ImageObserver observer) {
   1890         toolkit.lockAWT();
   1891         try {
   1892             return toolkit.checkImage(image, width, height, observer);
   1893         } finally {
   1894             toolkit.unlockAWT();
   1895         }
   1896     }
   1897 
   1898     /**
   1899      * Returns the construction status of a specified image that is being
   1900      * created.
   1901      *
   1902      * @param image
   1903      *            the image to be checked.
   1904      * @param observer
   1905      *            the ImageObserver object to be notified while the image is
   1906      *            being prepared.
   1907      * @return the ImageObserver flags of the current state of the image data.
   1908      */
   1909     public int checkImage(Image image, ImageObserver observer) {
   1910         toolkit.lockAWT();
   1911         try {
   1912             return toolkit.checkImage(image, -1, -1, observer);
   1913         } finally {
   1914             toolkit.unlockAWT();
   1915         }
   1916     }
   1917 
   1918     /**
   1919      * Coalesces the existed event with new event.
   1920      *
   1921      * @param existingEvent
   1922      *            the existing event in the EventQueue.
   1923      * @param newEvent
   1924      *            the new event to be posted to the EventQueue.
   1925      * @return the coalesced AWTEvent, or null if there is no coalescing done.
   1926      */
   1927     protected AWTEvent coalesceEvents(AWTEvent existingEvent, AWTEvent newEvent) {
   1928         toolkit.lockAWT();
   1929         try {
   1930             // Nothing to do:
   1931             // 1. Mouse events coalesced at WTK level
   1932             // 2. Paint events handled by RedrawManager
   1933             // This method is for overriding only
   1934             return null;
   1935         } finally {
   1936             toolkit.unlockAWT();
   1937         }
   1938     }
   1939 
   1940     /**
   1941      * Checks if this Component is a coalescer.
   1942      *
   1943      * @return true, if is coalescer.
   1944      */
   1945     boolean isCoalescer() {
   1946         return coalescer;
   1947     }
   1948 
   1949     /**
   1950      * Gets the relative event.
   1951      *
   1952      * @param id
   1953      *            the id.
   1954      * @return the relative event.
   1955      */
   1956     AWTEvent getRelativeEvent(int id) {
   1957         Integer idWrapper = new Integer(id);
   1958         eventsList = eventsTable.get(idWrapper);
   1959         if (eventsList == null) {
   1960             eventsList = new LinkedList<AWTEvent>();
   1961             eventsTable.put(idWrapper, eventsList);
   1962             return null;
   1963         }
   1964         if (eventsList.isEmpty()) {
   1965             return null;
   1966         }
   1967         return eventsList.getLast();
   1968     }
   1969 
   1970     /**
   1971      * Adds the new event.
   1972      *
   1973      * @param event
   1974      *            the event.
   1975      */
   1976     void addNewEvent(AWTEvent event) {
   1977         eventsList.addLast(event);
   1978     }
   1979 
   1980     /**
   1981      * Removes the relative event.
   1982      */
   1983     void removeRelativeEvent() {
   1984         eventsList.removeLast();
   1985     }
   1986 
   1987     /**
   1988      * Removes the next event.
   1989      *
   1990      * @param id
   1991      *            the id.
   1992      */
   1993     void removeNextEvent(int id) {
   1994         eventsTable.get(new Integer(id)).removeFirst();
   1995     }
   1996 
   1997     /**
   1998      * Creates the image with the specified ImageProducer.
   1999      *
   2000      * @param producer
   2001      *            the ImageProducer to be used for image creation.
   2002      * @return the image with the specified ImageProducer.
   2003      */
   2004     public Image createImage(ImageProducer producer) {
   2005         toolkit.lockAWT();
   2006         try {
   2007             return toolkit.createImage(producer);
   2008         } finally {
   2009             toolkit.unlockAWT();
   2010         }
   2011     }
   2012 
   2013     /**
   2014      * Creates an off-screen drawable image to be used for double buffering.
   2015      *
   2016      * @param width
   2017      *            the width of the image.
   2018      * @param height
   2019      *            the height of the image.
   2020      * @return the off-screen drawable image or null if the component is not
   2021      *         displayable or GraphicsEnvironment.isHeadless() method returns
   2022      *         true.
   2023      */
   2024     public Image createImage(int width, int height) {
   2025         toolkit.lockAWT();
   2026         try {
   2027             if (!isDisplayable()) {
   2028                 return null;
   2029             }
   2030             GraphicsConfiguration gc = getGraphicsConfiguration();
   2031             if (gc == null) {
   2032                 return null;
   2033             }
   2034             ColorModel cm = gc.getColorModel(Transparency.OPAQUE);
   2035             WritableRaster wr = cm.createCompatibleWritableRaster(width, height);
   2036             Image image = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
   2037             fillImageBackground(image, width, height);
   2038             return image;
   2039         } finally {
   2040             toolkit.unlockAWT();
   2041         }
   2042     }
   2043 
   2044     /**
   2045      * Creates an off-screen drawable image with the specified width, height and
   2046      * ImageCapabilities.
   2047      *
   2048      * @param width
   2049      *            the width.
   2050      * @param height
   2051      *            the height.
   2052      * @param caps
   2053      *            the ImageCapabilities.
   2054      * @return the volatile image.
   2055      * @throws AWTException
   2056      *             if an image with the specified capabilities cannot be
   2057      *             created.
   2058      */
   2059     public VolatileImage createVolatileImage(int width, int height, ImageCapabilities caps)
   2060             throws AWTException {
   2061         toolkit.lockAWT();
   2062         try {
   2063             if (!isDisplayable()) {
   2064                 return null;
   2065             }
   2066             GraphicsConfiguration gc = getGraphicsConfiguration();
   2067             if (gc == null) {
   2068                 return null;
   2069             }
   2070             VolatileImage image = gc.createCompatibleVolatileImage(width, height, caps);
   2071             fillImageBackground(image, width, height);
   2072             return image;
   2073         } finally {
   2074             toolkit.unlockAWT();
   2075         }
   2076     }
   2077 
   2078     /**
   2079      * Creates a volatile off-screen drawable image which is used for double
   2080      * buffering.
   2081      *
   2082      * @param width
   2083      *            the width of image.
   2084      * @param height
   2085      *            the height of image.
   2086      * @return the volatile image a volatile off-screen drawable image which is
   2087      *         used for double buffering or null if the component is not
   2088      *         displayable, or GraphicsEnvironment.isHeadless() method returns
   2089      *         true.
   2090      */
   2091     public VolatileImage createVolatileImage(int width, int height) {
   2092         toolkit.lockAWT();
   2093         try {
   2094             if (!isDisplayable()) {
   2095                 return null;
   2096             }
   2097             GraphicsConfiguration gc = getGraphicsConfiguration();
   2098             if (gc == null) {
   2099                 return null;
   2100             }
   2101             VolatileImage image = gc.createCompatibleVolatileImage(width, height);
   2102             fillImageBackground(image, width, height);
   2103             return image;
   2104         } finally {
   2105             toolkit.unlockAWT();
   2106         }
   2107     }
   2108 
   2109     /**
   2110      * Fill the image being created by createImage() or createVolatileImage()
   2111      * with the component's background color to prepare it for double-buffered
   2112      * painting.
   2113      *
   2114      * @param image
   2115      *            the image.
   2116      * @param width
   2117      *            the width.
   2118      * @param height
   2119      *            the height.
   2120      */
   2121     private void fillImageBackground(Image image, int width, int height) {
   2122         Graphics gr = image.getGraphics();
   2123         gr.setColor(getBackground());
   2124         gr.fillRect(0, 0, width, height);
   2125         gr.dispose();
   2126     }
   2127 
   2128     /**
   2129      * Delivers event.
   2130      *
   2131      * @param evt
   2132      *            the event.
   2133      * @deprecated Replaced by dispatchEvent(AWTEvent e) method.
   2134      */
   2135     @Deprecated
   2136     public void deliverEvent(Event evt) {
   2137         postEvent(evt);
   2138     }
   2139 
   2140     /**
   2141      * Prompts the layout manager to lay out this component.
   2142      */
   2143     public void doLayout() {
   2144         toolkit.lockAWT();
   2145         try {
   2146             layout();
   2147         } finally {
   2148             toolkit.unlockAWT();
   2149         }
   2150         // Implemented in Container
   2151     }
   2152 
   2153     /**
   2154      * Fire property change impl.
   2155      *
   2156      * @param propertyName
   2157      *            the property name.
   2158      * @param oldValue
   2159      *            the old value.
   2160      * @param newValue
   2161      *            the new value.
   2162      */
   2163     private void firePropertyChangeImpl(String propertyName, Object oldValue, Object newValue) {
   2164         PropertyChangeSupport pcs;
   2165         synchronized (componentLock) {
   2166             if (propertyChangeSupport == null) {
   2167                 return;
   2168             }
   2169             pcs = propertyChangeSupport;
   2170         }
   2171         pcs.firePropertyChange(propertyName, oldValue, newValue);
   2172     }
   2173 
   2174     /**
   2175      * Reports a bound property changes for int properties.
   2176      *
   2177      * @param propertyName
   2178      *            the property name.
   2179      * @param oldValue
   2180      *            the old property's value.
   2181      * @param newValue
   2182      *            the new property's value.
   2183      */
   2184     protected void firePropertyChange(String propertyName, int oldValue, int newValue) {
   2185         firePropertyChangeImpl(propertyName, new Integer(oldValue), new Integer(newValue));
   2186     }
   2187 
   2188     /**
   2189      * Report a bound property change for a boolean-valued property.
   2190      *
   2191      * @param propertyName
   2192      *            the property name.
   2193      * @param oldValue
   2194      *            the property's old value.
   2195      * @param newValue
   2196      *            the property's new value.
   2197      */
   2198     protected void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {
   2199         firePropertyChangeImpl(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
   2200     }
   2201 
   2202     /**
   2203      * Reports a bound property change for an Object-valued property.
   2204      *
   2205      * @param propertyName
   2206      *            the property name.
   2207      * @param oldValue
   2208      *            the property's old value.
   2209      * @param newValue
   2210      *            the property's new value.
   2211      */
   2212     protected void firePropertyChange(final String propertyName, final Object oldValue,
   2213             final Object newValue) {
   2214         firePropertyChangeImpl(propertyName, oldValue, newValue);
   2215     }
   2216 
   2217     /**
   2218      * Report a bound property change for a byte-valued property.
   2219      *
   2220      * @param propertyName
   2221      *            the property name.
   2222      * @param oldValue
   2223      *            the property's old value.
   2224      * @param newValue
   2225      *            the property's new value.
   2226      */
   2227     public void firePropertyChange(String propertyName, byte oldValue, byte newValue) {
   2228         firePropertyChangeImpl(propertyName, new Byte(oldValue), new Byte(newValue));
   2229     }
   2230 
   2231     /**
   2232      * Report a bound property change for a char-valued property.
   2233      *
   2234      * @param propertyName
   2235      *            the property name.
   2236      * @param oldValue
   2237      *            the old property's value.
   2238      * @param newValue
   2239      *            the new property's value.
   2240      */
   2241     public void firePropertyChange(String propertyName, char oldValue, char newValue) {
   2242         firePropertyChangeImpl(propertyName, new Character(oldValue), new Character(newValue));
   2243     }
   2244 
   2245     /**
   2246      * Report a bound property change for a short-valued property.
   2247      *
   2248      * @param propertyName
   2249      *            the property name.
   2250      * @param oldValue
   2251      *            the old property's value.
   2252      * @param newValue
   2253      *            the new property's value.
   2254      */
   2255     public void firePropertyChange(String propertyName, short oldValue, short newValue) {
   2256         firePropertyChangeImpl(propertyName, new Short(oldValue), new Short(newValue));
   2257     }
   2258 
   2259     /**
   2260      * Report a bound property change for a long-valued property.
   2261      *
   2262      * @param propertyName
   2263      *            the property name.
   2264      * @param oldValue
   2265      *            the old property's value.
   2266      * @param newValue
   2267      *            the new property's value.
   2268      */
   2269     public void firePropertyChange(String propertyName, long oldValue, long newValue) {
   2270         firePropertyChangeImpl(propertyName, new Long(oldValue), new Long(newValue));
   2271     }
   2272 
   2273     /**
   2274      * Report a bound property change for a float-valued property.
   2275      *
   2276      * @param propertyName
   2277      *            the property name.
   2278      * @param oldValue
   2279      *            the old property's value.
   2280      * @param newValue
   2281      *            the new property's value.
   2282      */
   2283     public void firePropertyChange(String propertyName, float oldValue, float newValue) {
   2284         firePropertyChangeImpl(propertyName, new Float(oldValue), new Float(newValue));
   2285     }
   2286 
   2287     /**
   2288      * Report a bound property change for a double-valued property.
   2289      *
   2290      * @param propertyName
   2291      *            the property name.
   2292      * @param oldValue
   2293      *            the old property's value.
   2294      * @param newValue
   2295      *            the new property's value.
   2296      */
   2297     public void firePropertyChange(String propertyName, double oldValue, double newValue) {
   2298         firePropertyChangeImpl(propertyName, new Double(oldValue), new Double(newValue));
   2299     }
   2300 
   2301     /**
   2302      * Gets the alignment along the x axis.
   2303      *
   2304      * @return the alignment along the x axis.
   2305      */
   2306     public float getAlignmentX() {
   2307         toolkit.lockAWT();
   2308         try {
   2309             return CENTER_ALIGNMENT;
   2310         } finally {
   2311             toolkit.unlockAWT();
   2312         }
   2313     }
   2314 
   2315     /**
   2316      * Gets the alignment along the y axis.
   2317      *
   2318      * @return the alignment along y axis.
   2319      */
   2320     public float getAlignmentY() {
   2321         toolkit.lockAWT();
   2322         try {
   2323             return CENTER_ALIGNMENT;
   2324         } finally {
   2325             toolkit.unlockAWT();
   2326         }
   2327     }
   2328 
   2329     /**
   2330      * Gets the background color for this component.
   2331      *
   2332      * @return the background color for this component.
   2333      */
   2334     public Color getBackground() {
   2335         toolkit.lockAWT();
   2336         try {
   2337             // ???AWT
   2338             /*
   2339              * if ((backColor == null) && (parent != null)) { return
   2340              * parent.getBackground(); }
   2341              */
   2342             return backColor;
   2343         } finally {
   2344             toolkit.unlockAWT();
   2345         }
   2346     }
   2347 
   2348     /**
   2349      * Gets the bounding rectangle of this component.
   2350      *
   2351      * @return the bounding rectangle of this component.
   2352      */
   2353     public Rectangle getBounds() {
   2354         toolkit.lockAWT();
   2355         try {
   2356             return bounds();
   2357         } finally {
   2358             toolkit.unlockAWT();
   2359         }
   2360     }
   2361 
   2362     /**
   2363      * Writes the data of the bounding rectangle to the specified Rectangle
   2364      * object.
   2365      *
   2366      * @param rv
   2367      *            the Rectangle object where the bounding rectangle's data is
   2368      *            stored.
   2369      * @return the bounding rectangle.
   2370      */
   2371     public Rectangle getBounds(Rectangle rv) {
   2372         toolkit.lockAWT();
   2373         try {
   2374             if (rv == null) {
   2375                 rv = new Rectangle();
   2376             }
   2377             rv.setBounds(x, y, w, h);
   2378             return rv;
   2379         } finally {
   2380             toolkit.unlockAWT();
   2381         }
   2382     }
   2383 
   2384     /**
   2385      * Gets the color model of the Component.
   2386      *
   2387      * @return the color model of the Component.
   2388      */
   2389     public ColorModel getColorModel() {
   2390         toolkit.lockAWT();
   2391         try {
   2392             return getToolkit().getColorModel();
   2393         } finally {
   2394             toolkit.unlockAWT();
   2395         }
   2396     }
   2397 
   2398     /**
   2399      * Gets the Component which contains the specified Point.
   2400      *
   2401      * @param p
   2402      *            the Point.
   2403      * @return the Component which contains the specified Point.
   2404      */
   2405     public Component getComponentAt(Point p) {
   2406         toolkit.lockAWT();
   2407         try {
   2408             return getComponentAt(p.x, p.y);
   2409         } finally {
   2410             toolkit.unlockAWT();
   2411         }
   2412     }
   2413 
   2414     /**
   2415      * Gets the Component which contains the point with the specified
   2416      * coordinates.
   2417      *
   2418      * @param x
   2419      *            the x coordinate of the point.
   2420      * @param y
   2421      *            the y coordinate of the point.
   2422      * @return the Component which contains the point with the specified
   2423      *         coordinates.
   2424      */
   2425     public Component getComponentAt(int x, int y) {
   2426         toolkit.lockAWT();
   2427         try {
   2428             return locate(x, y);
   2429         } finally {
   2430             toolkit.unlockAWT();
   2431         }
   2432     }
   2433 
   2434     /**
   2435      * Gets the component's orientation.
   2436      *
   2437      * @return the component's orientation.
   2438      */
   2439     public ComponentOrientation getComponentOrientation() {
   2440         toolkit.lockAWT();
   2441         try {
   2442             return orientation;
   2443         } finally {
   2444             toolkit.unlockAWT();
   2445         }
   2446     }
   2447 
   2448     /**
   2449      * Gets the cursor of the Component.
   2450      *
   2451      * @return the Cursor.
   2452      */
   2453     public Cursor getCursor() {
   2454         toolkit.lockAWT();
   2455         try {
   2456             if (cursor != null) {
   2457                 return cursor;
   2458                 // ???AWT
   2459                 /*
   2460                  * } else if (parent != null) { return parent.getCursor();
   2461                  */
   2462             }
   2463             return Cursor.getDefaultCursor();
   2464         } finally {
   2465             toolkit.unlockAWT();
   2466         }
   2467     }
   2468 
   2469     // ???AWT
   2470     /*
   2471      * public DropTarget getDropTarget() { toolkit.lockAWT(); try { return
   2472      * dropTarget; } finally { toolkit.unlockAWT(); } } public Container
   2473      * getFocusCycleRootAncestor() { toolkit.lockAWT(); try { for (Container c =
   2474      * parent; c != null; c = c.getParent()) { if (c.isFocusCycleRoot()) {
   2475      * return c; } } return null; } finally { toolkit.unlockAWT(); } }
   2476      * @SuppressWarnings("unchecked") public Set<AWTKeyStroke>
   2477      * getFocusTraversalKeys(int id) { toolkit.lockAWT(); try { Integer kId =
   2478      * new Integer(id); KeyboardFocusManager.checkTraversalKeysID(traversalKeys,
   2479      * kId); Set<? extends AWTKeyStroke> keys = traversalKeys.get(kId); if (keys
   2480      * == null && parent != null) { keys = parent.getFocusTraversalKeys(id); }
   2481      * if (keys == null) { keys =
   2482      * KeyboardFocusManager.getCurrentKeyboardFocusManager()
   2483      * .getDefaultFocusTraversalKeys(id); } return (Set<AWTKeyStroke>) keys; }
   2484      * finally { toolkit.unlockAWT(); } }
   2485      */
   2486 
   2487     /**
   2488      * Checks if the the focus traversal keys are enabled for this component.
   2489      *
   2490      * @return true, if the the focus traversal keys are enabled for this
   2491      *         component, false otherwise.
   2492      */
   2493     public boolean getFocusTraversalKeysEnabled() {
   2494         toolkit.lockAWT();
   2495         try {
   2496             return focusTraversalKeysEnabled;
   2497         } finally {
   2498             toolkit.unlockAWT();
   2499         }
   2500     }
   2501 
   2502     /**
   2503      * Gets the font metrics of the specified Font.
   2504      *
   2505      * @param f
   2506      *            the Font.
   2507      * @return the FontMetrics of the specified Font.
   2508      */
   2509     @SuppressWarnings("deprecation")
   2510     public FontMetrics getFontMetrics(Font f) {
   2511         return toolkit.getFontMetrics(f);
   2512     }
   2513 
   2514     /**
   2515      * Gets the foreground color of the Component.
   2516      *
   2517      * @return the foreground color of the Component.
   2518      */
   2519     public Color getForeground() {
   2520         toolkit.lockAWT();
   2521         try {
   2522             // ???AWT
   2523             /*
   2524              * if (foreColor == null && parent != null) { return
   2525              * parent.getForeground(); }
   2526              */
   2527             return foreColor;
   2528         } finally {
   2529             toolkit.unlockAWT();
   2530         }
   2531     }
   2532 
   2533     /**
   2534      * Gets the Graphics of the Component or null if this Component is not
   2535      * displayable.
   2536      *
   2537      * @return the Graphics of the Component or null if this Component is not
   2538      *         displayable.
   2539      */
   2540     public Graphics getGraphics() {
   2541         toolkit.lockAWT();
   2542         try {
   2543             if (!isDisplayable()) {
   2544                 return null;
   2545             }
   2546             Graphics g = behaviour.getGraphics(0, 0, w, h);
   2547             g.setColor(foreColor);
   2548             g.setFont(font);
   2549             return g;
   2550         } finally {
   2551             toolkit.unlockAWT();
   2552         }
   2553     }
   2554 
   2555     /**
   2556      * Gets the GraphicsConfiguration associated with this Component.
   2557      *
   2558      * @return the GraphicsConfiguration associated with this Component.
   2559      */
   2560     public GraphicsConfiguration getGraphicsConfiguration() {
   2561         // ???AWT
   2562         /*
   2563          * toolkit.lockAWT(); try { Window win = getWindowAncestor(); if (win ==
   2564          * null) { return null; } return win.getGraphicsConfiguration(); }
   2565          * finally { toolkit.unlockAWT(); }
   2566          */
   2567         return null;
   2568     }
   2569 
   2570     /**
   2571      * Gets the height of the Component.
   2572      *
   2573      * @return the height of the Component.
   2574      */
   2575     public int getHeight() {
   2576         toolkit.lockAWT();
   2577         try {
   2578             return h;
   2579         } finally {
   2580             toolkit.unlockAWT();
   2581         }
   2582     }
   2583 
   2584     /**
   2585      * Returns true if paint messages received from the operating system should
   2586      * be ignored.
   2587      *
   2588      * @return true if paint messages received from the operating system should
   2589      *         be ignored, false otherwise.
   2590      */
   2591     public boolean getIgnoreRepaint() {
   2592         toolkit.lockAWT();
   2593         try {
   2594             return ignoreRepaint;
   2595         } finally {
   2596             toolkit.unlockAWT();
   2597         }
   2598     }
   2599 
   2600     /**
   2601      * Gets the input context of this component for handling the communication
   2602      * with input methods when text is entered in this component.
   2603      *
   2604      * @return the InputContext used by this Component or null if no context is
   2605      *         specifined.
   2606      */
   2607     public InputContext getInputContext() {
   2608         toolkit.lockAWT();
   2609         try {
   2610             // ???AWT
   2611             /*
   2612              * Container parent = getParent(); if (parent != null) { return
   2613              * parent.getInputContext(); }
   2614              */
   2615             return null;
   2616         } finally {
   2617             toolkit.unlockAWT();
   2618         }
   2619     }
   2620 
   2621     /**
   2622      * Gets the input method request handler which supports requests from input
   2623      * methods for this component, or null for default.
   2624      *
   2625      * @return the input method request handler which supports requests from
   2626      *         input methods for this component, or null for default.
   2627      */
   2628     public InputMethodRequests getInputMethodRequests() {
   2629         return null;
   2630     }
   2631 
   2632     /**
   2633      * Gets the locale of this Component.
   2634      *
   2635      * @return the locale of this Component.
   2636      */
   2637     public Locale getLocale() {
   2638         toolkit.lockAWT();
   2639         try {
   2640             // ???AWT
   2641             /*
   2642              * if (locale == null) { if (parent == null) { if (this instanceof
   2643              * Window) { return Locale.getDefault(); } // awt.150=no parent
   2644              * throw new
   2645              * IllegalComponentStateException(Messages.getString("awt.150"));
   2646              * //$NON-NLS-1$ } return getParent().getLocale(); }
   2647              */
   2648             return locale;
   2649         } finally {
   2650             toolkit.unlockAWT();
   2651         }
   2652     }
   2653 
   2654     /**
   2655      * Gets the location of this component in the form of a point specifying the
   2656      * component's top-left corner in the screen's coordinate space.
   2657      *
   2658      * @return the Point giving the component's location in the screen's
   2659      *         coordinate space.
   2660      * @throws IllegalComponentStateException
   2661      *             if the component is not shown on the screen.
   2662      */
   2663     public Point getLocationOnScreen() throws IllegalComponentStateException {
   2664         toolkit.lockAWT();
   2665         try {
   2666             Point p = new Point();
   2667             if (isShowing()) {
   2668                 // ???AWT
   2669                 /*
   2670                  * Component comp; for (comp = this; comp != null && !(comp
   2671                  * instanceof Window); comp = comp .getParent()) {
   2672                  * p.translate(comp.getX(), comp.getY()); } if (comp instanceof
   2673                  * Window) { p.translate(comp.getX(), comp.getY()); }
   2674                  */
   2675                 return p;
   2676             }
   2677             // awt.151=component must be showing on the screen to determine its
   2678             // location
   2679             throw new IllegalComponentStateException(Messages.getString("awt.151")); //$NON-NLS-1$
   2680         } finally {
   2681             toolkit.unlockAWT();
   2682         }
   2683     }
   2684 
   2685     /**
   2686      * Gets the peer. This method should not be called directly by user
   2687      * applications.
   2688      *
   2689      * @return the ComponentPeer.
   2690      * @deprecated Replaced by isDisplayable().
   2691      */
   2692     @Deprecated
   2693     public ComponentPeer getPeer() {
   2694         toolkit.lockAWT();
   2695         try {
   2696             if (behaviour.isDisplayable()) {
   2697                 return peer;
   2698             }
   2699             return null;
   2700         } finally {
   2701             toolkit.unlockAWT();
   2702         }
   2703     }
   2704 
   2705     /**
   2706      * Gets an array of the property change listeners registered to this
   2707      * Component.
   2708      *
   2709      * @return an array of the PropertyChangeListeners registered to this
   2710      *         Component.
   2711      */
   2712     public PropertyChangeListener[] getPropertyChangeListeners() {
   2713         return getPropertyChangeSupport().getPropertyChangeListeners();
   2714     }
   2715 
   2716     /**
   2717      * Gets an array of PropertyChangeListener objects registered to this
   2718      * Component for the specified property.
   2719      *
   2720      * @param propertyName
   2721      *            the property name.
   2722      * @return an array of PropertyChangeListener objects registered to this
   2723      *         Component for the specified property.
   2724      */
   2725     public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
   2726         return getPropertyChangeSupport().getPropertyChangeListeners(propertyName);
   2727     }
   2728 
   2729     /**
   2730      * Gets the width of the Component.
   2731      *
   2732      * @return the width of the Component.
   2733      */
   2734     public int getWidth() {
   2735         toolkit.lockAWT();
   2736         try {
   2737             return w;
   2738         } finally {
   2739             toolkit.unlockAWT();
   2740         }
   2741     }
   2742 
   2743     /**
   2744      * Gets the x coordinate of the component's top-left corner.
   2745      *
   2746      * @return the x coordinate of the component's top-left corner.
   2747      */
   2748     public int getX() {
   2749         toolkit.lockAWT();
   2750         try {
   2751             return x;
   2752         } finally {
   2753             toolkit.unlockAWT();
   2754         }
   2755     }
   2756 
   2757     /**
   2758      * Gets the y coordinate of the component's top-left corner.
   2759      *
   2760      * @return the y coordinate of the component's top-left corner.
   2761      */
   2762     public int getY() {
   2763         toolkit.lockAWT();
   2764         try {
   2765             return y;
   2766         } finally {
   2767             toolkit.unlockAWT();
   2768         }
   2769     }
   2770 
   2771     /**
   2772      * Got the focus.
   2773      *
   2774      * @param evt
   2775      *            the Event.
   2776      * @param what
   2777      *            the Object.
   2778      * @return true, if successful.
   2779      * @deprecated Replaced by processFocusEvent(FocusEvent) method.
   2780      */
   2781     @Deprecated
   2782     public boolean gotFocus(Event evt, Object what) {
   2783         // to be overridden: do nothing,
   2784         // just return false to propagate event up to the parent container
   2785         return false;
   2786     }
   2787 
   2788     /**
   2789      * Handles event.
   2790      *
   2791      * @param evt
   2792      *            the Event.
   2793      * @return true, if successful.
   2794      * @deprecated Replaced by processEvent(AWTEvent) method.
   2795      */
   2796     @Deprecated
   2797     public boolean handleEvent(Event evt) {
   2798         switch (evt.id) {
   2799             case Event.ACTION_EVENT:
   2800                 return action(evt, evt.arg);
   2801             case Event.GOT_FOCUS:
   2802                 return gotFocus(evt, null);
   2803             case Event.LOST_FOCUS:
   2804                 return lostFocus(evt, null);
   2805             case Event.MOUSE_DOWN:
   2806                 return mouseDown(evt, evt.x, evt.y);
   2807             case Event.MOUSE_DRAG:
   2808                 return mouseDrag(evt, evt.x, evt.y);
   2809             case Event.MOUSE_ENTER:
   2810                 return mouseEnter(evt, evt.x, evt.y);
   2811             case Event.MOUSE_EXIT:
   2812                 return mouseExit(evt, evt.x, evt.y);
   2813             case Event.MOUSE_MOVE:
   2814                 return mouseMove(evt, evt.x, evt.y);
   2815             case Event.MOUSE_UP:
   2816                 return mouseUp(evt, evt.x, evt.y);
   2817             case Event.KEY_ACTION:
   2818             case Event.KEY_PRESS:
   2819                 return keyDown(evt, evt.key);
   2820             case Event.KEY_ACTION_RELEASE:
   2821             case Event.KEY_RELEASE:
   2822                 return keyUp(evt, evt.key);
   2823         }
   2824         return false;// event not handled
   2825     }
   2826 
   2827     /**
   2828      * Checks whether the Component is the focus owner or not.
   2829      *
   2830      * @return true, if the Component is the focus owner, false otherwise.
   2831      */
   2832     public boolean hasFocus() {
   2833         toolkit.lockAWT();
   2834         try {
   2835             // ???AWT: return isFocusOwner();
   2836             return false;
   2837         } finally {
   2838             toolkit.unlockAWT();
   2839         }
   2840     }
   2841 
   2842     /**
   2843      * Hides the Component.
   2844      *
   2845      * @deprecated Replaced by setVisible(boolean) method.
   2846      */
   2847     @Deprecated
   2848     public void hide() {
   2849         toolkit.lockAWT();
   2850         try {
   2851             if (!visible) {
   2852                 return;
   2853             }
   2854             prepare4HierarchyChange();
   2855             visible = false;
   2856             moveFocusOnHide();
   2857             behaviour.setVisible(false);
   2858             postEvent(new ComponentEvent(this, ComponentEvent.COMPONENT_HIDDEN));
   2859             // ???AWT: finishHierarchyChange(this, parent, 0);
   2860             notifyInputMethod(null);
   2861             // ???AWT: invalidateRealParent();
   2862         } finally {
   2863             toolkit.unlockAWT();
   2864         }
   2865     }
   2866 
   2867     /**
   2868      * Checks whether or not the point with the specified coordinates belongs to
   2869      * the Commponent.
   2870      *
   2871      * @param x
   2872      *            the x coordinate of the Point.
   2873      * @param y
   2874      *            the y coordinate of the Point.
   2875      * @return true, if the point with the specified coordinates belongs to the
   2876      *         Commponent, false otherwise.
   2877      * @deprecated Replaced by contains(int, int) method.
   2878      */
   2879     @Deprecated
   2880     public boolean inside(int x, int y) {
   2881         toolkit.lockAWT();
   2882         try {
   2883             return x >= 0 && x < getWidth() && y >= 0 && y < getHeight();
   2884         } finally {
   2885             toolkit.unlockAWT();
   2886         }
   2887     }
   2888 
   2889     /**
   2890      * Invalidates the component, this component and all parents above it are
   2891      * marked as needing to be laid out.
   2892      */
   2893     public void invalidate() {
   2894         toolkit.lockAWT();
   2895         try {
   2896             valid = false;
   2897             resetDefaultSize();
   2898             // ???AWT: invalidateRealParent();
   2899         } finally {
   2900             toolkit.unlockAWT();
   2901         }
   2902     }
   2903 
   2904     /**
   2905      * Checks whether or not the background color is set to this Component.
   2906      *
   2907      * @return true, if the background color is set to this Component, false
   2908      *         otherwise.
   2909      */
   2910     public boolean isBackgroundSet() {
   2911         toolkit.lockAWT();
   2912         try {
   2913             return backColor != null;
   2914         } finally {
   2915             toolkit.unlockAWT();
   2916         }
   2917     }
   2918 
   2919     /**
   2920      * Checks whether or not a cursor is set for the Component.
   2921      *
   2922      * @return true, if a cursor is set for the Component, false otherwise.
   2923      */
   2924     public boolean isCursorSet() {
   2925         toolkit.lockAWT();
   2926         try {
   2927             return cursor != null;
   2928         } finally {
   2929             toolkit.unlockAWT();
   2930         }
   2931     }
   2932 
   2933     /**
   2934      * Checks whether or not this Component is displayable.
   2935      *
   2936      * @return true, if this Component is displayable, false otherwise.
   2937      */
   2938     public boolean isDisplayable() {
   2939         toolkit.lockAWT();
   2940         try {
   2941             return behaviour.isDisplayable();
   2942         } finally {
   2943             toolkit.unlockAWT();
   2944         }
   2945     }
   2946 
   2947     /**
   2948      * Checks whether or not this component is painted to an buffer which is
   2949      * copied to the screen later.
   2950      *
   2951      * @return true, if this component is painted to an buffer which is copied
   2952      *         to the screen later, false otherwise.
   2953      */
   2954     public boolean isDoubleBuffered() {
   2955         toolkit.lockAWT();
   2956         try {
   2957             // false by default
   2958             return false;
   2959         } finally {
   2960             toolkit.unlockAWT();
   2961         }
   2962     }
   2963 
   2964     /**
   2965      * Checks whether or not this Component is enabled.
   2966      *
   2967      * @return true, if this Component is enabled, false otherwise.
   2968      */
   2969     public boolean isEnabled() {
   2970         toolkit.lockAWT();
   2971         try {
   2972             return enabled;
   2973         } finally {
   2974             toolkit.unlockAWT();
   2975         }
   2976     }
   2977 
   2978     /**
   2979      * "Recursive" isEnabled().
   2980      *
   2981      * @return true if not only component itself is enabled but its heavyweight
   2982      *         parent is also "indirectly" enabled.
   2983      */
   2984     boolean isIndirectlyEnabled() {
   2985         Component comp = this;
   2986         while (comp != null) {
   2987             if (!comp.isLightweight() && !comp.isEnabled()) {
   2988                 return false;
   2989             }
   2990             // ???AWT: comp = comp.getRealParent();
   2991         }
   2992         return true;
   2993     }
   2994 
   2995     /**
   2996      * Checks if the component is key enabled.
   2997      *
   2998      * @return true, if the component is enabled and indirectly enabled.
   2999      */
   3000     boolean isKeyEnabled() {
   3001         if (!isEnabled()) {
   3002             return false;
   3003         }
   3004         return isIndirectlyEnabled();
   3005     }
   3006 
   3007     /**
   3008      * Gets only parent of a child component, but not owner of a window.
   3009      *
   3010      * @return parent of child component, null if component is a top-level
   3011      *         (Window instance).
   3012      */
   3013     // ???AWT
   3014     /*
   3015      * Container getRealParent() { return (!(this instanceof Window) ?
   3016      * getParent() : null); } public boolean isFocusCycleRoot(Container
   3017      * container) { toolkit.lockAWT(); try { return getFocusCycleRootAncestor()
   3018      * == container; } finally { toolkit.unlockAWT(); } } public boolean
   3019      * isFocusOwner() { toolkit.lockAWT(); try { return
   3020      * KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() ==
   3021      * this; } finally { toolkit.unlockAWT(); } }
   3022      */
   3023 
   3024     /**
   3025      * Checks whether or not this Component can be focusable.
   3026      *
   3027      * @return true, if this Component can be focusable, false otherwise.
   3028      * @deprecated Replaced by isFocusable().
   3029      */
   3030     @Deprecated
   3031     public boolean isFocusTraversable() {
   3032         toolkit.lockAWT();
   3033         try {
   3034             overridenIsFocusable = false;
   3035             return focusable; // a Component must either be both focusable and
   3036             // focus traversable, or neither
   3037         } finally {
   3038             toolkit.unlockAWT();
   3039         }
   3040     }
   3041 
   3042     /**
   3043      * Checks if this Component can be focusable or not.
   3044      *
   3045      * @return true, if this Component can be focusable, false otherwise.
   3046      */
   3047     public boolean isFocusable() {
   3048         toolkit.lockAWT();
   3049         try {
   3050             return isFocusTraversable();
   3051         } finally {
   3052             toolkit.unlockAWT();
   3053         }
   3054     }
   3055 
   3056     /**
   3057      * Checks if the Font is set for this Component or not.
   3058      *
   3059      * @return true, if the Font is set, false otherwise.
   3060      */
   3061     public boolean isFontSet() {
   3062         toolkit.lockAWT();
   3063         try {
   3064             return font != null;
   3065         } finally {
   3066             toolkit.unlockAWT();
   3067         }
   3068     }
   3069 
   3070     /**
   3071      * Checks if foreground color is set for the Component or not.
   3072      *
   3073      * @return true, if is foreground color is set for the Component, false
   3074      *         otherwise.
   3075      */
   3076     public boolean isForegroundSet() {
   3077         toolkit.lockAWT();
   3078         try {
   3079             return foreColor != null;
   3080         } finally {
   3081             toolkit.unlockAWT();
   3082         }
   3083     }
   3084 
   3085     /**
   3086      * Returns true if this component has a lightweight peer.
   3087      *
   3088      * @return true, if this component has a lightweight peer, false if it has a
   3089      *         native peer or no peer.
   3090      */
   3091     public boolean isLightweight() {
   3092         toolkit.lockAWT();
   3093         try {
   3094             return behaviour.isLightweight();
   3095         } finally {
   3096             toolkit.unlockAWT();
   3097         }
   3098     }
   3099 
   3100     /**
   3101      * Checks whether or not this Component is shown.
   3102      *
   3103      * @return true, if this Component is shown, false otherwise.
   3104      */
   3105     public boolean isShowing() {
   3106         // ???AWT
   3107         /*
   3108          * toolkit.lockAWT(); try { return (isVisible() && isDisplayable() &&
   3109          * (parent != null) && parent.isShowing()); } finally {
   3110          * toolkit.unlockAWT(); }
   3111          */
   3112         return false;
   3113     }
   3114 
   3115     /**
   3116      * Checks whether or not this Component is visible.
   3117      *
   3118      * @return true, if the Component is visible, false otherwise.
   3119      */
   3120     public boolean isVisible() {
   3121         toolkit.lockAWT();
   3122         try {
   3123             return visible;
   3124         } finally {
   3125             toolkit.unlockAWT();
   3126         }
   3127     }
   3128 
   3129     /**
   3130      * Deprecated: replaced by processKeyEvent(KeyEvent) method.
   3131      *
   3132      * @param evt
   3133      *            the Event.
   3134      * @param key
   3135      *            the key code.
   3136      * @return true, if successful.
   3137      * @deprecated Replaced by replaced by processKeyEvent(KeyEvent) method.
   3138      */
   3139     @Deprecated
   3140     public boolean keyDown(Event evt, int key) {
   3141         // to be overridden: do nothing,
   3142         // just return false to propagate event up to the parent container
   3143         return false;
   3144     }
   3145 
   3146     /**
   3147      * Deprecated: replaced by processKeyEvent(KeyEvent) method.
   3148      *
   3149      * @param evt
   3150      *            the Event.
   3151      * @param key
   3152      *            the key code.
   3153      * @return true, if successful.
   3154      * @deprecated Replaced by processKeyEvent(KeyEvent) method.
   3155      */
   3156     @Deprecated
   3157     public boolean keyUp(Event evt, int key) {
   3158         // to be overridden: do nothing,
   3159         // just return false to propagate event up to the parent container
   3160         return false;
   3161     }
   3162 
   3163     /**
   3164      * Deprecated: Replaced by doLayout() method.
   3165      *
   3166      * @deprecated Replaced by doLayout() method.
   3167      */
   3168     @Deprecated
   3169     public void layout() {
   3170         toolkit.lockAWT();
   3171         try {
   3172             // Implemented in Container
   3173         } finally {
   3174             toolkit.unlockAWT();
   3175         }
   3176     }
   3177 
   3178     /**
   3179      * Deprecated: replaced by getComponentAt(int, int) method.
   3180      *
   3181      * @param x
   3182      *            the x coordinate.
   3183      * @param y
   3184      *            the y coordinate.
   3185      * @return The component.
   3186      * @deprecated Replaced by getComponentAt(int, int) method.
   3187      */
   3188     @Deprecated
   3189     public Component locate(int x, int y) {
   3190         toolkit.lockAWT();
   3191         try {
   3192             if (contains(x, y)) {
   3193                 return this;
   3194             }
   3195             return null;
   3196         } finally {
   3197             toolkit.unlockAWT();
   3198         }
   3199     }
   3200 
   3201     /**
   3202      * Deprecated: replaced by processFocusEvent(FocusEvent).
   3203      *
   3204      * @param evt
   3205      *            the Event.
   3206      * @param what
   3207      *            the Object.
   3208      * @return true, if successful.
   3209      * @deprecated Replaced by processFocusEvent(FocusEvent).
   3210      */
   3211     @Deprecated
   3212     public boolean lostFocus(Event evt, Object what) {
   3213         // to be overridden: do nothing,
   3214         // just return false to propagate event up to the parent container
   3215         return false;
   3216     }
   3217 
   3218     /**
   3219      * Deprecated: replaced by processMouseEvent(MouseEvent) method.
   3220      *
   3221      * @param evt
   3222      *            the MouseEvent.
   3223      * @param x
   3224      *            the x coordinate.
   3225      * @param y
   3226      *            the y coordinate.
   3227      * @return true, if successful.
   3228      * @deprecated Replaced by processMouseEvent(MouseEvent) method.
   3229      */
   3230     @Deprecated
   3231     public boolean mouseDown(Event evt, int x, int y) {
   3232         // to be overridden: do nothing,
   3233         // just return false to propagate event up to the parent container
   3234         return false;
   3235     }
   3236 
   3237     /**
   3238      * Deprecated: replaced by getMinimumSize() method.
   3239      *
   3240      * @param evt
   3241      *            the Event.
   3242      * @param x
   3243      *            the x coordinate.
   3244      * @param y
   3245      *            the y coordinate.
   3246      * @return true, if successful.
   3247      * @deprecated Replaced by getMinimumSize() method.
   3248      */
   3249     @Deprecated
   3250     public boolean mouseDrag(Event evt, int x, int y) {
   3251         // to be overridden: do nothing,
   3252         // just return false to propagate event up to the parent container
   3253         return false;
   3254     }
   3255 
   3256     /**
   3257      * Replaced by processMouseEvent(MouseEvent) method.
   3258      *
   3259      * @param evt
   3260      *            the Event.
   3261      * @param x
   3262      *            the x coordinate.
   3263      * @param y
   3264      *            the y coordinate.
   3265      * @return true, if successful.
   3266      * @deprecated replaced by processMouseEvent(MouseEvent) method.
   3267      */
   3268     @Deprecated
   3269     public boolean mouseEnter(Event evt, int x, int y) {
   3270         // to be overridden: do nothing,
   3271         // just return false to propagate event up to the parent container
   3272         return false;
   3273     }
   3274 
   3275     /**
   3276      * Replaced by processMouseEvent(MouseEvent) method.
   3277      *
   3278      * @param evt
   3279      *            the Event.
   3280      * @param x
   3281      *            the x coordinate.
   3282      * @param y
   3283      *            the y coordinate.
   3284      * @return true, if successful.
   3285      * @deprecated Replaced by processMouseEvent(MouseEvent) method.
   3286      */
   3287     @Deprecated
   3288     public boolean mouseExit(Event evt, int x, int y) {
   3289         // to be overridden: do nothing,
   3290         // just return false to propagate event up to the parent container
   3291         return false;
   3292     }
   3293 
   3294     /**
   3295      * Replaced by processMouseEvent(MouseEvent) method.
   3296      *
   3297      * @param evt
   3298      *            the Event.
   3299      * @param x
   3300      *            the x coordinate.
   3301      * @param y
   3302      *            the y coordinate.
   3303      * @deprecated Replaced by processMouseEvent(MouseEvent) method.
   3304      * @return true, if successful.
   3305      */
   3306     @Deprecated
   3307     public boolean mouseMove(Event evt, int x, int y) {
   3308         // to be overridden: do nothing,
   3309         // just return false to propagate event up to the parent container
   3310         return false;
   3311     }
   3312 
   3313     /**
   3314      * Replaced by processMouseEvent(MouseEvent) method.
   3315      *
   3316      * @param evt
   3317      *            the Event.
   3318      * @param x
   3319      *            the x coordinate.
   3320      * @param y
   3321      *            the y coordinate.
   3322      * @return true, if successful.
   3323      * @deprecated Replaced by processMouseEvent(MouseEvent) method.
   3324      */
   3325     @Deprecated
   3326     public boolean mouseUp(Event evt, int x, int y) {
   3327         // to be overridden: do nothing,
   3328         // just return false to propagate event up to the parent container
   3329         return false;
   3330     }
   3331 
   3332     /**
   3333      * Deprecated: replaced by setLocation(int, int) method.
   3334      *
   3335      * @param x
   3336      *            the x coordinates.
   3337      * @param y
   3338      *            the y coordinates.
   3339      * @deprecated Replaced by setLocation(int, int) method.
   3340      */
   3341     @Deprecated
   3342     public void move(int x, int y) {
   3343         toolkit.lockAWT();
   3344         try {
   3345             boundsMaskParam = NativeWindow.BOUNDS_NOSIZE;
   3346             setBounds(x, y, w, h);
   3347         } finally {
   3348             toolkit.unlockAWT();
   3349         }
   3350     }
   3351 
   3352     // ???AWT
   3353     /*
   3354      * @Deprecated public void nextFocus() { toolkit.lockAWT(); try {
   3355      * transferFocus(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); } finally {
   3356      * toolkit.unlockAWT(); } }
   3357      */
   3358 
   3359     /**
   3360      * Returns a string representation of the component's state.
   3361      *
   3362      * @return the string representation of the component's state.
   3363      */
   3364     protected String paramString() {
   3365         /*
   3366          * The format is based on 1.5 release behavior which can be revealed by
   3367          * the following code: Component c = new Component(){};
   3368          * c.setVisible(false); System.out.println(c);
   3369          */
   3370         toolkit.lockAWT();
   3371         try {
   3372             return getName() + "," + getX() + "," + getY() + "," + getWidth() + "x" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
   3373                     + getHeight() + (!isVisible() ? ",hidden" : ""); //$NON-NLS-1$ //$NON-NLS-2$
   3374         } finally {
   3375             toolkit.unlockAWT();
   3376         }
   3377     }
   3378 
   3379     @Deprecated
   3380     @SuppressWarnings("deprecation")
   3381     public boolean postEvent(Event evt) {
   3382         boolean handled = handleEvent(evt);
   3383         if (handled) {
   3384             return true;
   3385         }
   3386         // ???AWT
   3387         /*
   3388          * // propagate non-handled events up to parent Component par = parent;
   3389          * // try to call postEvent only on components which // override any of
   3390          * deprecated method handlers // while (par != null &&
   3391          * !par.deprecatedEventHandler) { // par = par.parent; // } // translate
   3392          * event coordinates before posting it to parent if (par != null) {
   3393          * evt.translate(x, y); par.postEvent(evt); }
   3394          */
   3395         return false;
   3396     }
   3397 
   3398     /**
   3399      * Prepares an image for rendering on the Component.
   3400      *
   3401      * @param image
   3402      *            the Image to be prepared.
   3403      * @param observer
   3404      *            the ImageObserver object to be notified as soon as the image
   3405      *            is prepared.
   3406      * @return true if the image has been fully prepared, false otherwise.
   3407      */
   3408     public boolean prepareImage(Image image, ImageObserver observer) {
   3409         toolkit.lockAWT();
   3410         try {
   3411             return toolkit.prepareImage(image, -1, -1, observer);
   3412         } finally {
   3413             toolkit.unlockAWT();
   3414         }
   3415     }
   3416 
   3417     /**
   3418      * Prepares an image for rendering on the Component with the specified
   3419      * width, height, and ImageObserver.
   3420      *
   3421      * @param image
   3422      *            the Image to be prepared.
   3423      * @param width
   3424      *            the width of scaled image.
   3425      * @param height
   3426      *            the height of scaled height.
   3427      * @param observer
   3428      *            the ImageObserver object to be notified as soon as the image
   3429      *            is prepared.
   3430      * @return true if the image is been fully prepared, false otherwise.
   3431      */
   3432     public boolean prepareImage(Image image, int width, int height, ImageObserver observer) {
   3433         toolkit.lockAWT();
   3434         try {
   3435             return toolkit.prepareImage(image, width, height, observer);
   3436         } finally {
   3437             toolkit.unlockAWT();
   3438         }
   3439     }
   3440 
   3441     /**
   3442      * Makes this Component undisplayable.
   3443      */
   3444     public void removeNotify() {
   3445         toolkit.lockAWT();
   3446         try {
   3447             // ???AWT
   3448             /*
   3449              * if (dropTarget != null) { dropTarget.removeNotify(peer); }
   3450              */
   3451             prepare4HierarchyChange();
   3452             // /???AWT: moveFocus();
   3453             behaviour.removeNotify();
   3454             // ???AWT: finishHierarchyChange(this, parent, 0);
   3455             removeNotifyInputContext();
   3456         } finally {
   3457             toolkit.unlockAWT();
   3458         }
   3459     }
   3460 
   3461     /**
   3462      * Calls InputContext.removeNotify.
   3463      */
   3464     private void removeNotifyInputContext() {
   3465         if (!inputMethodsEnabled) {
   3466             return;
   3467         }
   3468         InputContext ic = getInputContext();
   3469         if (ic != null) {
   3470             // ???AWT: ic.removeNotify(this);
   3471         }
   3472     }
   3473 
   3474     /**
   3475      * This method is called when some property of a component changes, making
   3476      * it unfocusable, e. g. hide(), removeNotify(), setEnabled(false),
   3477      * setFocusable(false) is called, and therefore automatic forward focus
   3478      * traversal is necessary
   3479      */
   3480     // ???AWT
   3481     /*
   3482      * void moveFocus() { // don't use transferFocus(), but query focus
   3483      * traversal policy directly // and if it returns null, transfer focus up
   3484      * cycle // and find next focusable component there KeyboardFocusManager kfm
   3485      * = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Container root =
   3486      * kfm.getCurrentFocusCycleRoot(); Component nextComp = this; boolean
   3487      * success = !isFocusOwner(); while (!success) { if (root !=
   3488      * nextComp.getFocusCycleRootAncestor()) { // component was probably removed
   3489      * from container // so focus will be lost in some time return; } nextComp =
   3490      * root.getFocusTraversalPolicy().getComponentAfter(root, nextComp); if
   3491      * (nextComp == this) { nextComp = null; // avoid looping } if (nextComp !=
   3492      * null) { success = nextComp.requestFocusInWindow(); } else { nextComp =
   3493      * root; root = root.getFocusCycleRootAncestor(); // if no acceptable
   3494      * component is found at all - clear global // focus owner if (root == null)
   3495      * { if (nextComp instanceof Window) { Window wnd = (Window) nextComp;
   3496      * wnd.setFocusOwner(null); wnd.setRequestedFocus(null); }
   3497      * kfm.clearGlobalFocusOwner(); return; } } } }
   3498      */
   3499 
   3500     /**
   3501      * For Container there's a difference between moving focus when being made
   3502      * invisible or made unfocusable in some other way, because when container
   3503      * is made invisible, component still remains visible, i. e. its hide() or
   3504      * setVisible() is not called.
   3505      */
   3506     void moveFocusOnHide() {
   3507         // ???AWT: moveFocus();
   3508     }
   3509 
   3510     /**
   3511      * Removes the property change listener registered for this component.
   3512      *
   3513      * @param listener
   3514      *            the PropertyChangeListener.
   3515      */
   3516     public void removePropertyChangeListener(PropertyChangeListener listener) {
   3517         getPropertyChangeSupport().removePropertyChangeListener(listener);
   3518     }
   3519 
   3520     /**
   3521      * Removes the property change listener registered fot this component for
   3522      * the specified propertyy.
   3523      *
   3524      * @param propertyName
   3525      *            the property name.
   3526      * @param listener
   3527      *            the PropertyChangeListener.
   3528      */
   3529     public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
   3530         getPropertyChangeSupport().removePropertyChangeListener(propertyName, listener);
   3531     }
   3532 
   3533     /**
   3534      * Repaints the specified rectangle of this component within tm
   3535      * milliseconds.
   3536      *
   3537      * @param tm
   3538      *            the time in milliseconds before updating.
   3539      * @param x
   3540      *            the x coordinate of Rectangle.
   3541      * @param y
   3542      *            the y coordinate of Rectangle.
   3543      * @param width
   3544      *            the width of Rectangle.
   3545      * @param height
   3546      *            the height of Rectangle.
   3547      */
   3548     public void repaint(long tm, int x, int y, int width, int height) {
   3549         // ???AWT
   3550         /*
   3551          * toolkit.lockAWT(); try { if (width <= 0 || height <= 0 ||
   3552          * (redrawManager == null) || !isShowing()) { return; } if (behaviour
   3553          * instanceof LWBehavior) { if (parent == null || !parent.visible ||
   3554          * !parent.behaviour.isDisplayable()) { return; } if (repaintRegion ==
   3555          * null) { repaintRegion = new MultiRectArea(new Rectangle(x, y, width,
   3556          * height)); } repaintRegion.intersect(new Rectangle(0, 0, this.w,
   3557          * this.h)); repaintRegion.translate(this.x, this.y);
   3558          * parent.repaintRegion = repaintRegion; repaintRegion = null;
   3559          * parent.repaint(tm, x + this.x, y + this.y, width, height); } else {
   3560          * if (repaintRegion != null) { redrawManager.addUpdateRegion(this,
   3561          * repaintRegion); repaintRegion = null; } else {
   3562          * redrawManager.addUpdateRegion(this, new Rectangle(x, y, width,
   3563          * height)); }
   3564          * toolkit.getSystemEventQueueCore().notifyEventMonitor(toolkit); } }
   3565          * finally { toolkit.unlockAWT(); }
   3566          */
   3567     }
   3568 
   3569     /**
   3570      * Post event.
   3571      *
   3572      * @param e
   3573      *            the e.
   3574      */
   3575     void postEvent(AWTEvent e) {
   3576         getToolkit().getSystemEventQueueImpl().postEvent(e);
   3577     }
   3578 
   3579     /**
   3580      * Repaints the specified Rectangle of this Component.
   3581      *
   3582      * @param x
   3583      *            the x coordinate of Rectangle.
   3584      * @param y
   3585      *            the y coordinate of Rectangle.
   3586      * @param width
   3587      *            the width of Rectangle.
   3588      * @param height
   3589      *            the height of Rectangle.
   3590      */
   3591     public void repaint(int x, int y, int width, int height) {
   3592         toolkit.lockAWT();
   3593         try {
   3594             repaint(0, x, y, width, height);
   3595         } finally {
   3596             toolkit.unlockAWT();
   3597         }
   3598     }
   3599 
   3600     /**
   3601      * Repaints this component.
   3602      */
   3603     public void repaint() {
   3604         toolkit.lockAWT();
   3605         try {
   3606             if (w > 0 && h > 0) {
   3607                 repaint(0, 0, 0, w, h);
   3608             }
   3609         } finally {
   3610             toolkit.unlockAWT();
   3611         }
   3612     }
   3613 
   3614     /**
   3615      * Repaints the component within tm milliseconds.
   3616      *
   3617      * @param tm
   3618      *            the time in milliseconds before updating.
   3619      */
   3620     public void repaint(long tm) {
   3621         toolkit.lockAWT();
   3622         try {
   3623             repaint(tm, 0, 0, w, h);
   3624         } finally {
   3625             toolkit.unlockAWT();
   3626         }
   3627     }
   3628 
   3629     /**
   3630      * Requests that this Component get the input focus temporarily. This
   3631      * component must be displayable, visible, and focusable.
   3632      *
   3633      * @param temporary
   3634      *            this parameter is true if the focus change is temporary, when
   3635      *            the window loses the focus.
   3636      * @return true if the focus change request is succeeded, false otherwise.
   3637      */
   3638     protected boolean requestFocus(boolean temporary) {
   3639         toolkit.lockAWT();
   3640         try {
   3641             // ???AWT: return requestFocusImpl(temporary, true, false);
   3642         } finally {
   3643             toolkit.unlockAWT();
   3644         }
   3645         // ???AWT
   3646         return false;
   3647     }
   3648 
   3649     /**
   3650      * Requests that this Component get the input focus. This component must be
   3651      * displayable, visible, and focusable.
   3652      */
   3653     public void requestFocus() {
   3654         toolkit.lockAWT();
   3655         try {
   3656             requestFocus(false);
   3657         } finally {
   3658             toolkit.unlockAWT();
   3659         }
   3660     }
   3661 
   3662     // ???AWT
   3663     /*
   3664      * protected boolean requestFocusInWindow(boolean temporary) {
   3665      * toolkit.lockAWT(); try { Window wnd = getWindowAncestor(); if ((wnd ==
   3666      * null) || !wnd.isFocused()) { return false; } return
   3667      * requestFocusImpl(temporary, false, false); } finally {
   3668      * toolkit.unlockAWT(); } } boolean requestFocusImpl(boolean temporary,
   3669      * boolean crossWindow, boolean rejectionRecovery) { if (!rejectionRecovery
   3670      * && isFocusOwner()) { return true; } Window wnd = getWindowAncestor();
   3671      * Container par = getRealParent(); if ((par != null) && par.isRemoved) {
   3672      * return false; } if (!isShowing() || !isFocusable() ||
   3673      * !wnd.isFocusableWindow()) { return false; } return
   3674      * KeyboardFocusManager.getCurrentKeyboardFocusManager().requestFocus(this,
   3675      * temporary, crossWindow, true); } public boolean requestFocusInWindow() {
   3676      * toolkit.lockAWT(); try { return requestFocusInWindow(false); } finally {
   3677      * toolkit.unlockAWT(); } }
   3678      */
   3679 
   3680     /**
   3681      * Deprecated: replaced by setBounds(int, int, int, int) method.
   3682      *
   3683      * @param x
   3684      *            the x coordinate.
   3685      * @param y
   3686      *            the y coordinate.
   3687      * @param w
   3688      *            the width.
   3689      * @param h
   3690      *            the height.
   3691      * @deprecated Replaced by setBounds(int, int, int, int) method.
   3692      */
   3693     @Deprecated
   3694     public void reshape(int x, int y, int w, int h) {
   3695         toolkit.lockAWT();
   3696         try {
   3697             setBounds(x, y, w, h, boundsMaskParam, true);
   3698             boundsMaskParam = 0;
   3699         } finally {
   3700             toolkit.unlockAWT();
   3701         }
   3702     }
   3703 
   3704     /**
   3705      * Sets rectangle for this Component to be the rectangle with the specified
   3706      * x,y coordinates of the top-left corner and the width and height.
   3707      *
   3708      * @param x
   3709      *            the x coordinate of the rectangle's top-left corner.
   3710      * @param y
   3711      *            the y coordinate of the rectangle's top-left corner.
   3712      * @param w
   3713      *            the width of rectangle.
   3714      * @param h
   3715      *            the height of rectangle.
   3716      */
   3717     public void setBounds(int x, int y, int w, int h) {
   3718         toolkit.lockAWT();
   3719         try {
   3720             reshape(x, y, w, h);
   3721         } finally {
   3722             toolkit.unlockAWT();
   3723         }
   3724     }
   3725 
   3726     /**
   3727      * Sets rectangle for this Component to be the rectangle with the specified
   3728      * x,y coordinates of the top-left corner and the width and height and posts
   3729      * the appropriate events.
   3730      *
   3731      * @param x
   3732      *            the x coordinate of the rectangle's top-left corner.
   3733      * @param y
   3734      *            the y coordinate of the rectangle's top-left corner.
   3735      * @param w
   3736      *            the width of rectangle.
   3737      * @param h
   3738      *            the height of rectangle.
   3739      * @param bMask
   3740      *            the bitmask of bounds options.
   3741      * @param updateBehavior
   3742      *            the whether to update the behavoir's bounds as well.
   3743      */
   3744     void setBounds(int x, int y, int w, int h, int bMask, boolean updateBehavior) {
   3745         int oldX = this.x;
   3746         int oldY = this.y;
   3747         int oldW = this.w;
   3748         int oldH = this.h;
   3749         setBoundsFields(x, y, w, h, bMask);
   3750         // Moved
   3751         if ((oldX != this.x) || (oldY != this.y)) {
   3752             // ???AWT: invalidateRealParent();
   3753             postEvent(new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED));
   3754             spreadHierarchyBoundsEvents(this, HierarchyEvent.ANCESTOR_MOVED);
   3755         }
   3756         // Resized
   3757         if ((oldW != this.w) || (oldH != this.h)) {
   3758             invalidate();
   3759             postEvent(new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED));
   3760             spreadHierarchyBoundsEvents(this, HierarchyEvent.ANCESTOR_RESIZED);
   3761         }
   3762         if (updateBehavior) {
   3763             behaviour.setBounds(this.x, this.y, this.w, this.h, bMask);
   3764         }
   3765         notifyInputMethod(new Rectangle(x, y, w, h));
   3766     }
   3767 
   3768     /**
   3769      * Calls InputContextImpl.notifyClientWindowChanged.
   3770      *
   3771      * @param bounds
   3772      *            the bounds.
   3773      */
   3774     void notifyInputMethod(Rectangle bounds) {
   3775         // only Window actually notifies IM of bounds change
   3776     }
   3777 
   3778     /**
   3779      * Sets the bounds fields.
   3780      *
   3781      * @param x
   3782      *            the x.
   3783      * @param y
   3784      *            the y.
   3785      * @param w
   3786      *            the w.
   3787      * @param h
   3788      *            the h.
   3789      * @param bMask
   3790      *            the b mask.
   3791      */
   3792     private void setBoundsFields(int x, int y, int w, int h, int bMask) {
   3793         if ((bMask & NativeWindow.BOUNDS_NOSIZE) == 0) {
   3794             this.w = w;
   3795             this.h = h;
   3796         }
   3797         if ((bMask & NativeWindow.BOUNDS_NOMOVE) == 0) {
   3798             this.x = x;
   3799             this.y = y;
   3800         }
   3801     }
   3802 
   3803     /**
   3804      * Gets the native insets.
   3805      *
   3806      * @return the native insets.
   3807      */
   3808     Insets getNativeInsets() {
   3809         return new Insets(0, 0, 0, 0);
   3810     }
   3811 
   3812     /**
   3813      * Gets the insets.
   3814      *
   3815      * @return the insets.
   3816      */
   3817     Insets getInsets() {
   3818         return new Insets(0, 0, 0, 0);
   3819     }
   3820 
   3821     /**
   3822      * Checks if is mouse exited expected.
   3823      *
   3824      * @return true, if is mouse exited expected.
   3825      */
   3826     boolean isMouseExitedExpected() {
   3827         return mouseExitedExpected;
   3828     }
   3829 
   3830     /**
   3831      * Sets the mouse exited expected.
   3832      *
   3833      * @param expected
   3834      *            the new mouse exited expected.
   3835      */
   3836     void setMouseExitedExpected(boolean expected) {
   3837         mouseExitedExpected = expected;
   3838     }
   3839 
   3840     /**
   3841      * Sets the new bounding rectangle for this Component.
   3842      *
   3843      * @param r
   3844      *            the new bounding rectangle.
   3845      */
   3846     public void setBounds(Rectangle r) {
   3847         toolkit.lockAWT();
   3848         try {
   3849             setBounds(r.x, r.y, r.width, r.height);
   3850         } finally {
   3851             toolkit.unlockAWT();
   3852         }
   3853     }
   3854 
   3855     /**
   3856      * Sets the component orientation which affects the component's elements and
   3857      * text within this component.
   3858      *
   3859      * @param o
   3860      *            the ComponentOrientation object.
   3861      */
   3862     public void setComponentOrientation(ComponentOrientation o) {
   3863         ComponentOrientation oldOrientation;
   3864         toolkit.lockAWT();
   3865         try {
   3866             oldOrientation = orientation;
   3867             orientation = o;
   3868         } finally {
   3869             toolkit.unlockAWT();
   3870         }
   3871         firePropertyChange("componentOrientation", oldOrientation, orientation); //$NON-NLS-1$
   3872         invalidate();
   3873     }
   3874 
   3875     /**
   3876      * Sets the specified cursor for this Component.
   3877      *
   3878      * @param cursor
   3879      *            the new Cursor.
   3880      */
   3881     public void setCursor(Cursor cursor) {
   3882         toolkit.lockAWT();
   3883         try {
   3884             this.cursor = cursor;
   3885             setCursor();
   3886         } finally {
   3887             toolkit.unlockAWT();
   3888         }
   3889     }
   3890 
   3891     /**
   3892      * Set current cursor shape to Component's Cursor.
   3893      */
   3894     void setCursor() {
   3895         if (isDisplayable() && isShowing()) {
   3896             Rectangle absRect = new Rectangle(getLocationOnScreen(), getSize());
   3897             Point absPointerPos = toolkit.dispatcher.mouseDispatcher.getPointerPos();
   3898             // ???AWT
   3899             /*
   3900              * if (absRect.contains(absPointerPos)) { // set Cursor only on
   3901              * top-level Windows(on X11) Window topLevelWnd =
   3902              * getWindowAncestor(); if (topLevelWnd != null) { Point pointerPos
   3903              * = MouseDispatcher.convertPoint(null, absPointerPos, topLevelWnd);
   3904              * Component compUnderCursor =
   3905              * topLevelWnd.findComponentAt(pointerPos); // if (compUnderCursor
   3906              * == this || // compUnderCursor.getCursorAncestor() == this) {
   3907              * NativeWindow wnd = topLevelWnd.getNativeWindow(); if
   3908              * (compUnderCursor != null && wnd != null) {
   3909              * compUnderCursor.getRealCursor().getNativeCursor()
   3910              * .setCursor(wnd.getId()); } // } } }
   3911              */
   3912         }
   3913     }
   3914 
   3915     /**
   3916      * Gets the ancestor Cursor if Component is disabled (directly or via an
   3917      * ancestor) even if Cursor is explicitly set.
   3918      *
   3919      * @param value
   3920      *            the value.
   3921      * @return the actual Cursor to be displayed.
   3922      */
   3923     // ???AWT
   3924     /*
   3925      * Cursor getRealCursor() { Component cursorAncestor = getCursorAncestor();
   3926      * return cursorAncestor != null ? cursorAncestor.getCursor() :
   3927      * Cursor.getDefaultCursor(); }
   3928      */
   3929 
   3930     /**
   3931      * Gets the ancestor(or component itself) whose cursor is set when pointer
   3932      * is inside component
   3933      *
   3934      * @return the actual Cursor to be displayed.
   3935      */
   3936     // ???AWT
   3937     /*
   3938      * Component getCursorAncestor() { Component comp; for (comp = this; comp !=
   3939      * null; comp = comp.getParent()) { if (comp instanceof Window ||
   3940      * comp.isCursorSet() && comp.isKeyEnabled()) { return comp; } } return
   3941      * null; } public void setDropTarget(DropTarget dt) { toolkit.lockAWT(); try
   3942      * { if (dropTarget == dt) { return; } DropTarget oldDropTarget =
   3943      * dropTarget; dropTarget = dt; if (oldDropTarget != null) { if
   3944      * (behaviour.isDisplayable()) { oldDropTarget.removeNotify(peer); }
   3945      * oldDropTarget.setComponent(null); } if (dt != null) {
   3946      * dt.setComponent(this); if (behaviour.isDisplayable()) {
   3947      * dt.addNotify(peer); } } } finally { toolkit.unlockAWT(); } }
   3948      */
   3949 
   3950     /**
   3951      * Sets this component to the "enabled" or "disabled" state depending on the
   3952      * specified boolean parameter.
   3953      *
   3954      * @param value
   3955      *            true if this component should be enabled; false if this
   3956      *            component should be disabled.
   3957      */
   3958     public void setEnabled(boolean value) {
   3959         toolkit.lockAWT();
   3960         try {
   3961             enable(value);
   3962         } finally {
   3963             toolkit.unlockAWT();
   3964         }
   3965     }
   3966 
   3967     /**
   3968      * Sets the enabled impl.
   3969      *
   3970      * @param value
   3971      *            the new enabled impl.
   3972      */
   3973     void setEnabledImpl(boolean value) {
   3974         if (enabled != value) {
   3975             enabled = value;
   3976             setCursor();
   3977             if (!enabled) {
   3978                 moveFocusOnHide();
   3979             }
   3980             behaviour.setEnabled(value);
   3981         }
   3982     }
   3983 
   3984     // ???AWT
   3985     /*
   3986      * private void fireAccessibleStateChange(AccessibleState state, boolean
   3987      * value) { if (behaviour.isLightweight()) { return; } AccessibleContext ac
   3988      * = getAccessibleContext(); if (ac != null) { AccessibleState oldValue =
   3989      * null; AccessibleState newValue = null; if (value) { newValue = state; }
   3990      * else { oldValue = state; }
   3991      * ac.firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
   3992      * oldValue, newValue); } }
   3993      */
   3994 
   3995     // ???AWT
   3996     /*
   3997      * public void setFocusTraversalKeys(int id, Set<? extends AWTKeyStroke>
   3998      * keystrokes) { Set<? extends AWTKeyStroke> oldTraversalKeys; String
   3999      * propName = "FocusTraversalKeys"; //$NON-NLS-1$ toolkit.lockAWT(); try {
   4000      * Integer kId = new Integer(id);
   4001      * KeyboardFocusManager.checkTraversalKeysID(traversalKeys, kId);
   4002      * Map<Integer, Set<? extends AWTKeyStroke>> keys = new HashMap<Integer,
   4003      * Set<? extends AWTKeyStroke>>(); for (int kid : traversalIDs) { Integer
   4004      * key = new Integer(kid); keys.put(key, getFocusTraversalKeys(kid)); }
   4005      * KeyboardFocusManager.checkKeyStrokes(traversalIDs, keys, kId,
   4006      * keystrokes); oldTraversalKeys = traversalKeys.get(new Integer(id)); //
   4007      * put a copy of keystrokes object into map: Set<? extends AWTKeyStroke>
   4008      * newKeys = keystrokes; if (keystrokes != null) { newKeys = new
   4009      * HashSet<AWTKeyStroke>(keystrokes); } traversalKeys.put(kId, newKeys);
   4010      * String direction = ""; //$NON-NLS-1$ switch (id) { case
   4011      * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS: direction = "forward";
   4012      * //$NON-NLS-1$ break; case KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS:
   4013      * direction = "backward"; //$NON-NLS-1$ break; case
   4014      * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS: direction = "upCycle";
   4015      * //$NON-NLS-1$ break; case KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS:
   4016      * direction = "downCycle"; //$NON-NLS-1$ break; } propName = direction +
   4017      * propName; } finally { toolkit.unlockAWT(); } firePropertyChange(propName,
   4018      * oldTraversalKeys, keystrokes); }
   4019      */
   4020 
   4021     /**
   4022      * Sets the focus traversal keys state for this component.
   4023      *
   4024      * @param value
   4025      *            true if the focus traversal keys state is enabled, false if
   4026      *            the focus traversal keys state is disabled.
   4027      */
   4028     public void setFocusTraversalKeysEnabled(boolean value) {
   4029         boolean oldFocusTraversalKeysEnabled;
   4030         toolkit.lockAWT();
   4031         try {
   4032             oldFocusTraversalKeysEnabled = focusTraversalKeysEnabled;
   4033             focusTraversalKeysEnabled = value;
   4034         } finally {
   4035             toolkit.unlockAWT();
   4036         }
   4037         firePropertyChange("focusTraversalKeysEnabled", oldFocusTraversalKeysEnabled, //$NON-NLS-1$
   4038                 focusTraversalKeysEnabled);
   4039     }
   4040 
   4041     // ???AWT
   4042     /*
   4043      * public void setFocusable(boolean focusable) { boolean oldFocusable;
   4044      * toolkit.lockAWT(); try { calledSetFocusable = true; oldFocusable =
   4045      * this.focusable; this.focusable = focusable; if (!focusable) {
   4046      * moveFocus(); } } finally { toolkit.unlockAWT(); }
   4047      * firePropertyChange("focusable", oldFocusable, focusable); //$NON-NLS-1$ }
   4048      * public Font getFont() { toolkit.lockAWT(); try { return (font == null) &&
   4049      * (parent != null) ? parent.getFont() : font; } finally {
   4050      * toolkit.unlockAWT(); } }
   4051      */
   4052 
   4053     /**
   4054      * Sets the font for this Component.
   4055      *
   4056      * @param f
   4057      *            the new font of the Component.
   4058      */
   4059     public void setFont(Font f) {
   4060         Font oldFont;
   4061         toolkit.lockAWT();
   4062         try {
   4063             oldFont = font;
   4064             setFontImpl(f);
   4065         } finally {
   4066             toolkit.unlockAWT();
   4067         }
   4068         firePropertyChange("font", oldFont, font); //$NON-NLS-1$
   4069     }
   4070 
   4071     /**
   4072      * Sets the font impl.
   4073      *
   4074      * @param f
   4075      *            the new font impl.
   4076      */
   4077     void setFontImpl(Font f) {
   4078         font = f;
   4079         invalidate();
   4080         if (isShowing()) {
   4081             repaint();
   4082         }
   4083     }
   4084 
   4085     /**
   4086      * Invalidate the component if it inherits the font from the parent. This
   4087      * method is overridden in Container.
   4088      *
   4089      * @return true if the component was invalidated, false otherwise.
   4090      */
   4091     boolean propagateFont() {
   4092         if (font == null) {
   4093             invalidate();
   4094             return true;
   4095         }
   4096         return false;
   4097     }
   4098 
   4099     /**
   4100      * Sets the foreground color for this Component.
   4101      *
   4102      * @param c
   4103      *            the new foreground color.
   4104      */
   4105     public void setForeground(Color c) {
   4106         Color oldFgColor;
   4107         toolkit.lockAWT();
   4108         try {
   4109             oldFgColor = foreColor;
   4110             foreColor = c;
   4111         } finally {
   4112             toolkit.unlockAWT();
   4113         }
   4114         firePropertyChange("foreground", oldFgColor, foreColor); //$NON-NLS-1$
   4115         repaint();
   4116     }
   4117 
   4118     /**
   4119      * Sets the background color for the Component.
   4120      *
   4121      * @param c
   4122      *            the new background color for this component.
   4123      */
   4124     public void setBackground(Color c) {
   4125         Color oldBkColor;
   4126         toolkit.lockAWT();
   4127         try {
   4128             oldBkColor = backColor;
   4129             backColor = c;
   4130         } finally {
   4131             toolkit.unlockAWT();
   4132         }
   4133         firePropertyChange("background", oldBkColor, backColor); //$NON-NLS-1$
   4134         repaint();
   4135     }
   4136 
   4137     /**
   4138      * Sets the flag for whether paint messages received from the operating
   4139      * system should be ignored or not.
   4140      *
   4141      * @param value
   4142      *            true if paint messages received from the operating system
   4143      *            should be ignored, false otherwise.
   4144      */
   4145     public void setIgnoreRepaint(boolean value) {
   4146         toolkit.lockAWT();
   4147         try {
   4148             ignoreRepaint = value;
   4149         } finally {
   4150             toolkit.unlockAWT();
   4151         }
   4152     }
   4153 
   4154     /**
   4155      * Sets the locale of the component.
   4156      *
   4157      * @param locale
   4158      *            the new Locale.
   4159      */
   4160     public void setLocale(Locale locale) {
   4161         Locale oldLocale;
   4162         toolkit.lockAWT();
   4163         try {
   4164             oldLocale = this.locale;
   4165             this.locale = locale;
   4166         } finally {
   4167             toolkit.unlockAWT();
   4168         }
   4169         firePropertyChange("locale", oldLocale, locale); //$NON-NLS-1$
   4170     }
   4171 
   4172     /**
   4173      * Sets the location of the Component to the specified point.
   4174      *
   4175      * @param p
   4176      *            the new location of the Component.
   4177      */
   4178     public void setLocation(Point p) {
   4179         toolkit.lockAWT();
   4180         try {
   4181             setLocation(p.x, p.y);
   4182         } finally {
   4183             toolkit.unlockAWT();
   4184         }
   4185     }
   4186 
   4187     /**
   4188      * Sets the location of the Component to the specified x, y coordinates.
   4189      *
   4190      * @param x
   4191      *            the x coordinate.
   4192      * @param y
   4193      *            the y coordinate.
   4194      */
   4195     public void setLocation(int x, int y) {
   4196         toolkit.lockAWT();
   4197         try {
   4198             move(x, y);
   4199         } finally {
   4200             toolkit.unlockAWT();
   4201         }
   4202     }
   4203 
   4204     /**
   4205      * Sets the visibility state of the component.
   4206      *
   4207      * @param b
   4208      *            true if the component is visible, false if the component is
   4209      *            not shown.
   4210      */
   4211     public void setVisible(boolean b) {
   4212         // show() & hide() are not deprecated for Window,
   4213         // so have to call them from setVisible()
   4214         show(b);
   4215     }
   4216 
   4217     /**
   4218      * Deprecated: replaced by setVisible(boolean) method.
   4219      *
   4220      * @deprecated Replaced by setVisible(boolean) method.
   4221      */
   4222     @Deprecated
   4223     public void show() {
   4224         toolkit.lockAWT();
   4225         try {
   4226             if (visible) {
   4227                 return;
   4228             }
   4229             prepare4HierarchyChange();
   4230             mapToDisplay(true);
   4231             validate();
   4232             visible = true;
   4233             behaviour.setVisible(true);
   4234             postEvent(new ComponentEvent(this, ComponentEvent.COMPONENT_SHOWN));
   4235             // ???AWT: finishHierarchyChange(this, parent, 0);
   4236             notifyInputMethod(new Rectangle(x, y, w, h));
   4237             // ???AWT: invalidateRealParent();
   4238         } finally {
   4239             toolkit.unlockAWT();
   4240         }
   4241     }
   4242 
   4243     /**
   4244      * Deprecated: replaced by setVisible(boolean) method.
   4245      *
   4246      * @param b
   4247      *            the visibility's state.
   4248      * @deprecated Replaced by setVisible(boolean) method.
   4249      */
   4250     @Deprecated
   4251     public void show(boolean b) {
   4252         if (b) {
   4253             show();
   4254         } else {
   4255             hide();
   4256         }
   4257     }
   4258 
   4259     // ???AWT
   4260     /*
   4261      * void transferFocus(int dir) { Container root = null; if (this instanceof
   4262      * Container) { Container cont = (Container) this; if
   4263      * (cont.isFocusCycleRoot()) { root = cont.getFocusTraversalRoot(); } } if
   4264      * (root == null) { root = getFocusCycleRootAncestor(); } // transfer focus
   4265      * up cycle if root is unreachable Component comp = this; while ((root !=
   4266      * null) && !(root.isFocusCycleRoot() && root.isShowing() &&
   4267      * root.isEnabled() && root .isFocusable())) { comp = root; root =
   4268      * root.getFocusCycleRootAncestor(); } if (root == null) { return; }
   4269      * FocusTraversalPolicy policy = root.getFocusTraversalPolicy(); Component
   4270      * nextComp = null; switch (dir) { case
   4271      * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS: nextComp =
   4272      * policy.getComponentAfter(root, comp); break; case
   4273      * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS: nextComp =
   4274      * policy.getComponentBefore(root, comp); break; } if (nextComp != null) {
   4275      * nextComp.requestFocus(false); } } public void transferFocus() {
   4276      * toolkit.lockAWT(); try { nextFocus(); } finally { toolkit.unlockAWT(); }
   4277      * } public void transferFocusBackward() { toolkit.lockAWT(); try {
   4278      * transferFocus(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); } finally {
   4279      * toolkit.unlockAWT(); } } public void transferFocusUpCycle() {
   4280      * toolkit.lockAWT(); try { KeyboardFocusManager kfm =
   4281      * KeyboardFocusManager.getCurrentKeyboardFocusManager(); Container root =
   4282      * kfm.getCurrentFocusCycleRoot(); if(root == null) { return; } boolean
   4283      * success = false; Component nextComp = null; Container newRoot = root; do
   4284      * { nextComp = newRoot instanceof Window ?
   4285      * newRoot.getFocusTraversalPolicy() .getDefaultComponent(newRoot) :
   4286      * newRoot; newRoot = newRoot.getFocusCycleRootAncestor(); if (nextComp ==
   4287      * null) { break; } success = nextComp.requestFocusInWindow(); if (newRoot
   4288      * == null) { break; } kfm.setGlobalCurrentFocusCycleRoot(newRoot); } while
   4289      * (!success); if (!success && root != newRoot) {
   4290      * kfm.setGlobalCurrentFocusCycleRoot(root); } } finally {
   4291      * toolkit.unlockAWT(); } }
   4292      */
   4293 
   4294     /**
   4295      * Validates that this component has a valid layout.
   4296      */
   4297     public void validate() {
   4298         toolkit.lockAWT();
   4299         try {
   4300             if (!behaviour.isDisplayable()) {
   4301                 return;
   4302             }
   4303             validateImpl();
   4304         } finally {
   4305             toolkit.unlockAWT();
   4306         }
   4307     }
   4308 
   4309     /**
   4310      * Validate impl.
   4311      */
   4312     void validateImpl() {
   4313         valid = true;
   4314     }
   4315 
   4316     /**
   4317      * Gets the native window.
   4318      *
   4319      * @return the native window.
   4320      */
   4321     NativeWindow getNativeWindow() {
   4322         return behaviour.getNativeWindow();
   4323     }
   4324 
   4325     /**
   4326      * Checks whether or not a maximum size is set for the Component.
   4327      *
   4328      * @return true, if the maximum size is set for the Component, false
   4329      *         otherwise.
   4330      */
   4331     public boolean isMaximumSizeSet() {
   4332         toolkit.lockAWT();
   4333         try {
   4334             return maximumSize != null;
   4335         } finally {
   4336             toolkit.unlockAWT();
   4337         }
   4338     }
   4339 
   4340     /**
   4341      * Checks whether or not the minimum size is set for the component.
   4342      *
   4343      * @return true, if the minimum size is set for the component, false
   4344      *         otherwise.
   4345      */
   4346     public boolean isMinimumSizeSet() {
   4347         toolkit.lockAWT();
   4348         try {
   4349             return minimumSize != null;
   4350         } finally {
   4351             toolkit.unlockAWT();
   4352         }
   4353     }
   4354 
   4355     /**
   4356      * Checks whether or not the preferred size is set for the Component.
   4357      *
   4358      * @return true, if the preferred size is set for the Component, false
   4359      *         otherwise.
   4360      */
   4361     public boolean isPreferredSizeSet() {
   4362         toolkit.lockAWT();
   4363         try {
   4364             return preferredSize != null;
   4365         } finally {
   4366             toolkit.unlockAWT();
   4367         }
   4368     }
   4369 
   4370     /**
   4371      * Gets the maximum size of the Component.
   4372      *
   4373      * @return the maximum size of the Component.
   4374      */
   4375     public Dimension getMaximumSize() {
   4376         toolkit.lockAWT();
   4377         try {
   4378             return isMaximumSizeSet() ? new Dimension(maximumSize) : new Dimension(Short.MAX_VALUE,
   4379                     Short.MAX_VALUE);
   4380         } finally {
   4381             toolkit.unlockAWT();
   4382         }
   4383     }
   4384 
   4385     /**
   4386      * Gets the minimum size of the Component.
   4387      *
   4388      * @return the minimum size of the Component.
   4389      */
   4390     public Dimension getMinimumSize() {
   4391         toolkit.lockAWT();
   4392         try {
   4393             return minimumSize();
   4394         } finally {
   4395             toolkit.unlockAWT();
   4396         }
   4397     }
   4398 
   4399     /**
   4400      * Deprecated: replaced by getMinimumSize() method.
   4401      *
   4402      * @return the Dimension.
   4403      * @deprecated Replaced by getMinimumSize() method.
   4404      */
   4405     @Deprecated
   4406     public Dimension minimumSize() {
   4407         toolkit.lockAWT();
   4408         try {
   4409             if (isMinimumSizeSet()) {
   4410                 return (Dimension)minimumSize.clone();
   4411             }
   4412             Dimension defSize = getDefaultMinimumSize();
   4413             if (defSize != null) {
   4414                 return (Dimension)defSize.clone();
   4415             }
   4416             return isDisplayable() ? new Dimension(1, 1) : new Dimension(w, h);
   4417         } finally {
   4418             toolkit.unlockAWT();
   4419         }
   4420     }
   4421 
   4422     /**
   4423      * Gets the preferred size of the Component.
   4424      *
   4425      * @return the preferred size of the Component.
   4426      */
   4427     public Dimension getPreferredSize() {
   4428         toolkit.lockAWT();
   4429         try {
   4430             return preferredSize();
   4431         } finally {
   4432             toolkit.unlockAWT();
   4433         }
   4434     }
   4435 
   4436     /**
   4437      * Deprecated: replaced by getPreferredSize() method.
   4438      *
   4439      * @return the Dimension.
   4440      * @deprecated Replaced by getPreferredSize() method.
   4441      */
   4442     @Deprecated
   4443     public Dimension preferredSize() {
   4444         toolkit.lockAWT();
   4445         try {
   4446             if (isPreferredSizeSet()) {
   4447                 return new Dimension(preferredSize);
   4448             }
   4449             Dimension defSize = getDefaultPreferredSize();
   4450             if (defSize != null) {
   4451                 return new Dimension(defSize);
   4452             }
   4453             return new Dimension(getMinimumSize());
   4454         } finally {
   4455             toolkit.unlockAWT();
   4456         }
   4457     }
   4458 
   4459     /**
   4460      * Sets the maximum size of the Component.
   4461      *
   4462      * @param maximumSize
   4463      *            the new maximum size of the Component.
   4464      */
   4465     public void setMaximumSize(Dimension maximumSize) {
   4466         Dimension oldMaximumSize;
   4467         toolkit.lockAWT();
   4468         try {
   4469             oldMaximumSize = this.maximumSize;
   4470             if (oldMaximumSize != null) {
   4471                 oldMaximumSize = oldMaximumSize.getSize();
   4472             }
   4473             if (this.maximumSize == null) {
   4474                 if (maximumSize != null) {
   4475                     this.maximumSize = new Dimension(maximumSize);
   4476                 }
   4477             } else {
   4478                 if (maximumSize != null) {
   4479                     this.maximumSize.setSize(maximumSize);
   4480                 } else {
   4481                     this.maximumSize = null;
   4482                 }
   4483             }
   4484         } finally {
   4485             toolkit.unlockAWT();
   4486         }
   4487         firePropertyChange("maximumSize", oldMaximumSize, this.maximumSize); //$NON-NLS-1$
   4488         toolkit.lockAWT();
   4489         try {
   4490             // ???AWT: invalidateRealParent();
   4491         } finally {
   4492             toolkit.unlockAWT();
   4493         }
   4494     }
   4495 
   4496     /**
   4497      * Sets the minimum size of the Component.
   4498      *
   4499      * @param minimumSize
   4500      *            the new minimum size of the Component.
   4501      */
   4502     public void setMinimumSize(Dimension minimumSize) {
   4503         Dimension oldMinimumSize;
   4504         toolkit.lockAWT();
   4505         try {
   4506             oldMinimumSize = this.minimumSize;
   4507             if (oldMinimumSize != null) {
   4508                 oldMinimumSize = oldMinimumSize.getSize();
   4509             }
   4510             if (this.minimumSize == null) {
   4511                 if (minimumSize != null) {
   4512                     this.minimumSize = new Dimension(minimumSize);
   4513                 }
   4514             } else {
   4515                 if (minimumSize != null) {
   4516                     this.minimumSize.setSize(minimumSize);
   4517                 } else {
   4518                     this.minimumSize = null;
   4519                 }
   4520             }
   4521         } finally {
   4522             toolkit.unlockAWT();
   4523         }
   4524         firePropertyChange("minimumSize", oldMinimumSize, this.minimumSize); //$NON-NLS-1$
   4525         toolkit.lockAWT();
   4526         try {
   4527             // ???AWT: invalidateRealParent();
   4528         } finally {
   4529             toolkit.unlockAWT();
   4530         }
   4531     }
   4532 
   4533     /**
   4534      * Sets the preferred size of the Component.
   4535      *
   4536      * @param preferredSize
   4537      *            the new preferred size of the Component.
   4538      */
   4539     public void setPreferredSize(Dimension preferredSize) {
   4540         Dimension oldPreferredSize;
   4541         toolkit.lockAWT();
   4542         try {
   4543             oldPreferredSize = this.preferredSize;
   4544             if (oldPreferredSize != null) {
   4545                 oldPreferredSize = oldPreferredSize.getSize();
   4546             }
   4547             if (this.preferredSize == null) {
   4548                 if (preferredSize != null) {
   4549                     this.preferredSize = new Dimension(preferredSize);
   4550                 }
   4551             } else {
   4552                 if (preferredSize != null) {
   4553                     this.preferredSize.setSize(preferredSize);
   4554                 } else {
   4555                     this.preferredSize = null;
   4556                 }
   4557             }
   4558         } finally {
   4559             toolkit.unlockAWT();
   4560         }
   4561         firePropertyChange("preferredSize", oldPreferredSize, this.preferredSize); //$NON-NLS-1$
   4562         toolkit.lockAWT();
   4563         try {
   4564             // ???AWT: invalidateRealParent();
   4565         } finally {
   4566             toolkit.unlockAWT();
   4567         }
   4568     }
   4569 
   4570     // ???AWT
   4571     /*
   4572      * RedrawManager getRedrawManager() { if (parent == null) { return null; }
   4573      * return parent.getRedrawManager(); }
   4574      */
   4575 
   4576     /**
   4577      * Checks if is focusability explicitly set.
   4578      *
   4579      * @return true if component has a focusable peer.
   4580      */
   4581     // ???AWT
   4582     /*
   4583      * boolean isPeerFocusable() { // The recommendations for Windows and Unix
   4584      * are that // Canvases, Labels, Panels, Scrollbars, ScrollPanes, Windows,
   4585      * // and lightweight Components have non-focusable peers, // and all other
   4586      * Components have focusable peers. if (this instanceof Canvas || this
   4587      * instanceof Label || this instanceof Panel || this instanceof Scrollbar ||
   4588      * this instanceof ScrollPane || this instanceof Window || isLightweight())
   4589      * { return false; } return true; }
   4590      */
   4591 
   4592     /**
   4593      * @return true if focusability was explicitly set via a call to
   4594      *         setFocusable() or via overriding isFocusable() or
   4595      *         isFocusTraversable().
   4596      */
   4597     boolean isFocusabilityExplicitlySet() {
   4598         return calledSetFocusable || overridenIsFocusable;
   4599     }
   4600 
   4601     /**
   4602      * Paints the component and all of its subcomponents.
   4603      *
   4604      * @param g
   4605      *            the Graphics to be used for painting.
   4606      */
   4607     public void paintAll(Graphics g) {
   4608         toolkit.lockAWT();
   4609         try {
   4610             paint(g);
   4611         } finally {
   4612             toolkit.unlockAWT();
   4613         }
   4614     }
   4615 
   4616     /**
   4617      * Updates this Component.
   4618      *
   4619      * @param g
   4620      *            the Graphics to be used for updating.
   4621      */
   4622     public void update(Graphics g) {
   4623         toolkit.lockAWT();
   4624         try {
   4625             if (!isLightweight() && !isPrepainter()) {
   4626                 g.setColor(getBackground());
   4627                 g.fillRect(0, 0, w, h);
   4628                 g.setColor(getForeground());
   4629             }
   4630             paint(g);
   4631         } finally {
   4632             toolkit.unlockAWT();
   4633         }
   4634     }
   4635 
   4636     /**
   4637      * Paints this component.
   4638      *
   4639      * @param g
   4640      *            the Graphics to be used for painting.
   4641      */
   4642     public void paint(Graphics g) {
   4643         toolkit.lockAWT();
   4644         try {
   4645             // Just to nothing
   4646         } finally {
   4647             toolkit.unlockAWT();
   4648         }
   4649     }
   4650 
   4651     /**
   4652      * Prepares the component to be painted.
   4653      *
   4654      * @param g
   4655      *            the Graphics to be used for painting.
   4656      */
   4657     void prepaint(Graphics g) {
   4658         // Just to nothing. For overriding.
   4659     }
   4660 
   4661     /**
   4662      * Checks if is prepainter.
   4663      *
   4664      * @return true, if is prepainter.
   4665      */
   4666     boolean isPrepainter() {
   4667         return false;
   4668     }
   4669 
   4670     /**
   4671      * Prepare4 hierarchy change.
   4672      */
   4673     void prepare4HierarchyChange() {
   4674         if (hierarchyChangingCounter++ == 0) {
   4675             wasShowing = isShowing();
   4676             wasDisplayable = isDisplayable();
   4677             prepareChildren4HierarchyChange();
   4678         }
   4679     }
   4680 
   4681     /**
   4682      * Prepare children4 hierarchy change.
   4683      */
   4684     void prepareChildren4HierarchyChange() {
   4685         // To be inherited by Container
   4686     }
   4687 
   4688     // ???AWT
   4689     /*
   4690      * void finishHierarchyChange(Component changed, Container changedParent,
   4691      * int ancestorFlags) { if (--hierarchyChangingCounter == 0) { int
   4692      * changeFlags = ancestorFlags; if (wasShowing != isShowing()) { changeFlags
   4693      * |= HierarchyEvent.SHOWING_CHANGED; } if (wasDisplayable !=
   4694      * isDisplayable()) { changeFlags |= HierarchyEvent.DISPLAYABILITY_CHANGED;
   4695      * } if (changeFlags > 0) { postEvent(new HierarchyEvent(this,
   4696      * HierarchyEvent.HIERARCHY_CHANGED, changed, changedParent, changeFlags));
   4697      * } finishChildrenHierarchyChange(changed, changedParent, ancestorFlags); }
   4698      * } void finishChildrenHierarchyChange(Component changed, Container
   4699      * changedParent, int ancestorFlags) { // To be inherited by Container }
   4700      * void postHierarchyBoundsEvents(Component changed, int id) { postEvent(new
   4701      * HierarchyEvent(this, id, changed, null, 0)); }
   4702      */
   4703 
   4704     /**
   4705      * Spread hierarchy bounds events.
   4706      *
   4707      * @param changed
   4708      *            the changed.
   4709      * @param id
   4710      *            the id.
   4711      */
   4712     void spreadHierarchyBoundsEvents(Component changed, int id) {
   4713         // To be inherited by Container
   4714     }
   4715 
   4716     /**
   4717      * Dispatches an event to this component.
   4718      *
   4719      * @param e
   4720      *            the Event.
   4721      */
   4722     public final void dispatchEvent(AWTEvent e) {
   4723         // ???AWT
   4724         /*
   4725          * if (e.isConsumed()) { return; } if (e instanceof PaintEvent) {
   4726          * toolkit.dispatchAWTEvent(e); processPaintEvent((PaintEvent) e);
   4727          * return; } KeyboardFocusManager kfm =
   4728          * KeyboardFocusManager.getCurrentKeyboardFocusManager(); if
   4729          * (!e.dispatchedByKFM && kfm.dispatchEvent(e)) { return; } if (e
   4730          * instanceof KeyEvent) { KeyEvent ke = (KeyEvent) e; // consumes
   4731          * KeyEvent which represents a focus traversal key if
   4732          * (getFocusTraversalKeysEnabled()) { kfm.processKeyEvent(this, ke); if
   4733          * (ke.isConsumed()) { return; } } } if (inputMethodsEnabled &&
   4734          * dispatchToIM && e.isPosted && dispatchEventToIM(e)) { return; } if
   4735          * (e.getID() == WindowEvent.WINDOW_ICONIFIED) {
   4736          * notifyInputMethod(null); } AWTEvent.EventDescriptor descriptor =
   4737          * toolkit.eventTypeLookup.getEventDescriptor(e);
   4738          * toolkit.dispatchAWTEvent(e); if (descriptor != null) { if
   4739          * (isEventEnabled(descriptor.eventMask) ||
   4740          * (getListeners(descriptor.listenerType).length > 0)) {
   4741          * processEvent(e); } // input events can be consumed by user listeners:
   4742          * if (!e.isConsumed() && ((enabledAWTEvents & descriptor.eventMask) !=
   4743          * 0)) { postprocessEvent(e, descriptor.eventMask); } }
   4744          * postDeprecatedEvent(e);
   4745          */
   4746     }
   4747 
   4748     /**
   4749      * Post deprecated event.
   4750      *
   4751      * @param e
   4752      *            the e.
   4753      */
   4754     private void postDeprecatedEvent(AWTEvent e) {
   4755         if (deprecatedEventHandler) {
   4756             Event evt = e.getEvent();
   4757             if (evt != null) {
   4758                 postEvent(evt);
   4759             }
   4760         }
   4761     }
   4762 
   4763     /**
   4764      * Postprocess event.
   4765      *
   4766      * @param e
   4767      *            the e.
   4768      * @param eventMask
   4769      *            the event mask.
   4770      */
   4771     void postprocessEvent(AWTEvent e, long eventMask) {
   4772         toolkit.lockAWT();
   4773         try {
   4774             // call system listeners under AWT lock
   4775             if (eventMask == AWTEvent.FOCUS_EVENT_MASK) {
   4776                 preprocessFocusEvent((FocusEvent)e);
   4777             } else if (eventMask == AWTEvent.KEY_EVENT_MASK) {
   4778                 preprocessKeyEvent((KeyEvent)e);
   4779             } else if (eventMask == AWTEvent.MOUSE_EVENT_MASK) {
   4780                 preprocessMouseEvent((MouseEvent)e);
   4781             } else if (eventMask == AWTEvent.MOUSE_MOTION_EVENT_MASK) {
   4782                 preprocessMouseMotionEvent((MouseEvent)e);
   4783             } else if (eventMask == AWTEvent.COMPONENT_EVENT_MASK) {
   4784                 preprocessComponentEvent((ComponentEvent)e);
   4785             } else if (eventMask == AWTEvent.MOUSE_WHEEL_EVENT_MASK) {
   4786                 preprocessMouseWheelEvent((MouseWheelEvent)e);
   4787             } else if (eventMask == AWTEvent.INPUT_METHOD_EVENT_MASK) {
   4788                 preprocessInputMethodEvent((InputMethodEvent)e);
   4789             }
   4790         } finally {
   4791             toolkit.unlockAWT();
   4792         }
   4793     }
   4794 
   4795     /**
   4796      * Preprocess input method event.
   4797      *
   4798      * @param e
   4799      *            the e.
   4800      */
   4801     private void preprocessInputMethodEvent(InputMethodEvent e) {
   4802         processInputMethodEventImpl(e, inputMethodListeners.getSystemListeners());
   4803     }
   4804 
   4805     /**
   4806      * Preprocess mouse wheel event.
   4807      *
   4808      * @param e
   4809      *            the e.
   4810      */
   4811     private void preprocessMouseWheelEvent(MouseWheelEvent e) {
   4812         processMouseWheelEventImpl(e, mouseWheelListeners.getSystemListeners());
   4813     }
   4814 
   4815     /**
   4816      * Process mouse wheel event impl.
   4817      *
   4818      * @param e
   4819      *            the e.
   4820      * @param c
   4821      *            the c.
   4822      */
   4823     private void processMouseWheelEventImpl(MouseWheelEvent e, Collection<MouseWheelListener> c) {
   4824         for (MouseWheelListener listener : c) {
   4825             switch (e.getID()) {
   4826                 case MouseEvent.MOUSE_WHEEL:
   4827                     listener.mouseWheelMoved(e);
   4828                     break;
   4829             }
   4830         }
   4831     }
   4832 
   4833     /**
   4834      * Preprocess component event.
   4835      *
   4836      * @param e
   4837      *            the e.
   4838      */
   4839     private void preprocessComponentEvent(ComponentEvent e) {
   4840         processComponentEventImpl(e, componentListeners.getSystemListeners());
   4841     }
   4842 
   4843     /**
   4844      * Preprocess mouse motion event.
   4845      *
   4846      * @param e
   4847      *            the e.
   4848      */
   4849     void preprocessMouseMotionEvent(MouseEvent e) {
   4850         processMouseMotionEventImpl(e, mouseMotionListeners.getSystemListeners());
   4851     }
   4852 
   4853     /**
   4854      * Preprocess mouse event.
   4855      *
   4856      * @param e
   4857      *            the e
   4858      */
   4859     void preprocessMouseEvent(MouseEvent e) {
   4860         processMouseEventImpl(e, mouseListeners.getSystemListeners());
   4861     }
   4862 
   4863     /**
   4864      * Preprocess key event.
   4865      *
   4866      * @param e
   4867      *            the e.
   4868      */
   4869     void preprocessKeyEvent(KeyEvent e) {
   4870         processKeyEventImpl(e, keyListeners.getSystemListeners());
   4871     }
   4872 
   4873     /**
   4874      * Preprocess focus event.
   4875      *
   4876      * @param e
   4877      *            the e.
   4878      */
   4879     void preprocessFocusEvent(FocusEvent e) {
   4880         processFocusEventImpl(e, focusListeners.getSystemListeners());
   4881     }
   4882 
   4883     /**
   4884      * Processes AWTEvent occurred on this component.
   4885      *
   4886      * @param e
   4887      *            the AWTEvent.
   4888      */
   4889     protected void processEvent(AWTEvent e) {
   4890         long eventMask = toolkit.eventTypeLookup.getEventMask(e);
   4891         if (eventMask == AWTEvent.COMPONENT_EVENT_MASK) {
   4892             processComponentEvent((ComponentEvent)e);
   4893         } else if (eventMask == AWTEvent.FOCUS_EVENT_MASK) {
   4894             processFocusEvent((FocusEvent)e);
   4895         } else if (eventMask == AWTEvent.KEY_EVENT_MASK) {
   4896             processKeyEvent((KeyEvent)e);
   4897         } else if (eventMask == AWTEvent.MOUSE_EVENT_MASK) {
   4898             processMouseEvent((MouseEvent)e);
   4899         } else if (eventMask == AWTEvent.MOUSE_WHEEL_EVENT_MASK) {
   4900             processMouseWheelEvent((MouseWheelEvent)e);
   4901         } else if (eventMask == AWTEvent.MOUSE_MOTION_EVENT_MASK) {
   4902             processMouseMotionEvent((MouseEvent)e);
   4903         } else if (eventMask == AWTEvent.HIERARCHY_EVENT_MASK) {
   4904             processHierarchyEvent((HierarchyEvent)e);
   4905         } else if (eventMask == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) {
   4906             processHierarchyBoundsEvent((HierarchyEvent)e);
   4907         } else if (eventMask == AWTEvent.INPUT_METHOD_EVENT_MASK) {
   4908             processInputMethodEvent((InputMethodEvent)e);
   4909         }
   4910     }
   4911 
   4912     /**
   4913      * Gets an array of all listener's objects based on the specified listener
   4914      * type and registered to this Component.
   4915      *
   4916      * @param listenerType
   4917      *            the listener type.
   4918      * @return an array of all listener's objects based on the specified
   4919      *         listener type and registered to this Component.
   4920      */
   4921     @SuppressWarnings("unchecked")
   4922     public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
   4923         if (ComponentListener.class.isAssignableFrom(listenerType)) {
   4924             return (T[])getComponentListeners();
   4925         } else if (FocusListener.class.isAssignableFrom(listenerType)) {
   4926             return (T[])getFocusListeners();
   4927         } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
   4928             return (T[])getHierarchyBoundsListeners();
   4929         } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
   4930             return (T[])getHierarchyListeners();
   4931         } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
   4932             return (T[])getInputMethodListeners();
   4933         } else if (KeyListener.class.isAssignableFrom(listenerType)) {
   4934             return (T[])getKeyListeners();
   4935         } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
   4936             return (T[])getMouseWheelListeners();
   4937         } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
   4938             return (T[])getMouseMotionListeners();
   4939         } else if (MouseListener.class.isAssignableFrom(listenerType)) {
   4940             return (T[])getMouseListeners();
   4941         } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
   4942             return (T[])getPropertyChangeListeners();
   4943         }
   4944         return (T[])Array.newInstance(listenerType, 0);
   4945     }
   4946 
   4947     /**
   4948      * Process paint event.
   4949      *
   4950      * @param event
   4951      *            the event.
   4952      */
   4953     private void processPaintEvent(PaintEvent event) {
   4954         if (redrawManager == null) {
   4955             return;
   4956         }
   4957         Rectangle clipRect = event.getUpdateRect();
   4958         if ((clipRect.width <= 0) || (clipRect.height <= 0)) {
   4959             return;
   4960         }
   4961         Graphics g = getGraphics();
   4962         if (g == null) {
   4963             return;
   4964         }
   4965         initGraphics(g, event);
   4966         if (!getIgnoreRepaint()) {
   4967             if (event.getID() == PaintEvent.PAINT) {
   4968                 paint(g);
   4969             } else {
   4970                 update(g);
   4971             }
   4972         }
   4973         g.dispose();
   4974     }
   4975 
   4976     /**
   4977      * Inits the graphics.
   4978      *
   4979      * @param g
   4980      *            the g.
   4981      * @param e
   4982      *            the e.
   4983      */
   4984     void initGraphics(Graphics g, PaintEvent e) {
   4985         Rectangle clip = e.getUpdateRect();
   4986         if (clip instanceof ClipRegion) {
   4987             g.setClip(((ClipRegion)clip).getClip());
   4988         } else {
   4989             g.setClip(clip);
   4990         }
   4991         if (isPrepainter()) {
   4992             prepaint(g);
   4993         } else if (!isLightweight() && (e.getID() == PaintEvent.PAINT)) {
   4994             g.setColor(getBackground());
   4995             g.fillRect(0, 0, w, h);
   4996         }
   4997         g.setFont(getFont());
   4998         g.setColor(getForeground());
   4999     }
   5000 
   5001     /**
   5002      * Enables the events with the specified event mask to be delivered to this
   5003      * component.
   5004      *
   5005      * @param eventsToEnable
   5006      *            the events mask which specifies the types of events to enable.
   5007      */
   5008     protected final void enableEvents(long eventsToEnable) {
   5009         toolkit.lockAWT();
   5010         try {
   5011             enabledEvents |= eventsToEnable;
   5012             deprecatedEventHandler = false;
   5013         } finally {
   5014             toolkit.unlockAWT();
   5015         }
   5016     }
   5017 
   5018     /**
   5019      * Enable awt events.
   5020      *
   5021      * @param eventsToEnable
   5022      *            the events to enable.
   5023      */
   5024     private void enableAWTEvents(long eventsToEnable) {
   5025         enabledAWTEvents |= eventsToEnable;
   5026     }
   5027 
   5028     /**
   5029      * Disables the events with types specified by the specified event mask from
   5030      * being delivered to this component.
   5031      *
   5032      * @param eventsToDisable
   5033      *            the event mask specifying the event types.
   5034      */
   5035     protected final void disableEvents(long eventsToDisable) {
   5036         toolkit.lockAWT();
   5037         try {
   5038             enabledEvents &= ~eventsToDisable;
   5039         } finally {
   5040             toolkit.unlockAWT();
   5041         }
   5042     }
   5043 
   5044     /*
   5045      * For use in MouseDispatcher only. Really it checks not only mouse events.
   5046      */
   5047     /**
   5048      * Checks if is mouse event enabled.
   5049      *
   5050      * @param eventMask
   5051      *            the event mask.
   5052      * @return true, if is mouse event enabled.
   5053      */
   5054     boolean isMouseEventEnabled(long eventMask) {
   5055         return (isEventEnabled(eventMask) || (enabledAWTEvents & eventMask) != 0);
   5056     }
   5057 
   5058     /**
   5059      * Checks if is event enabled.
   5060      *
   5061      * @param eventMask
   5062      *            the event mask.
   5063      * @return true, if is event enabled.
   5064      */
   5065     boolean isEventEnabled(long eventMask) {
   5066         return ((enabledEvents & eventMask) != 0);
   5067     }
   5068 
   5069     /**
   5070      * Enables or disables input method support for this component.
   5071      *
   5072      * @param enable
   5073      *            true to enable input method support, false to disable it.
   5074      */
   5075     public void enableInputMethods(boolean enable) {
   5076         toolkit.lockAWT();
   5077         try {
   5078             if (!enable) {
   5079                 removeNotifyInputContext();
   5080             }
   5081             inputMethodsEnabled = enable;
   5082         } finally {
   5083             toolkit.unlockAWT();
   5084         }
   5085     }
   5086 
   5087     /**
   5088      * Gets an array of all component's listeners registered for this component.
   5089      *
   5090      * @return an array of all component's listeners registered for this
   5091      *         component.
   5092      */
   5093     public ComponentListener[] getComponentListeners() {
   5094         return componentListeners.getUserListeners(new ComponentListener[0]);
   5095     }
   5096 
   5097     /**
   5098      * Adds the specified component listener to the Component for receiving
   5099      * component's event.
   5100      *
   5101      * @param l
   5102      *            the ComponentListener.
   5103      */
   5104     public void addComponentListener(ComponentListener l) {
   5105         componentListeners.addUserListener(l);
   5106     }
   5107 
   5108     /**
   5109      * Removes the component listener registered for this Component.
   5110      *
   5111      * @param l
   5112      *            the ComponentListener.
   5113      */
   5114     public void removeComponentListener(ComponentListener l) {
   5115         componentListeners.removeUserListener(l);
   5116     }
   5117 
   5118     /**
   5119      * Processes a component event that has occurred on this component by
   5120      * dispatching them to any registered ComponentListener objects.
   5121      *
   5122      * @param e
   5123      *            the ComponentEvent.
   5124      */
   5125     protected void processComponentEvent(ComponentEvent e) {
   5126         processComponentEventImpl(e, componentListeners.getUserListeners());
   5127     }
   5128 
   5129     /**
   5130      * Process component event impl.
   5131      *
   5132      * @param e
   5133      *            the e.
   5134      * @param c
   5135      *            the c.
   5136      */
   5137     private void processComponentEventImpl(ComponentEvent e, Collection<ComponentListener> c) {
   5138         for (ComponentListener listener : c) {
   5139             switch (e.getID()) {
   5140                 case ComponentEvent.COMPONENT_HIDDEN:
   5141                     listener.componentHidden(e);
   5142                     break;
   5143                 case ComponentEvent.COMPONENT_MOVED:
   5144                     listener.componentMoved(e);
   5145                     break;
   5146                 case ComponentEvent.COMPONENT_RESIZED:
   5147                     listener.componentResized(e);
   5148                     break;
   5149                 case ComponentEvent.COMPONENT_SHOWN:
   5150                     listener.componentShown(e);
   5151                     break;
   5152             }
   5153         }
   5154     }
   5155 
   5156     /**
   5157      * Gets an array of focus listeners registered for this Component.
   5158      *
   5159      * @return the array of focus listeners registered for this Component.
   5160      */
   5161     public FocusListener[] getFocusListeners() {
   5162         return focusListeners.getUserListeners(new FocusListener[0]);
   5163     }
   5164 
   5165     /**
   5166      * Adds the specified focus listener to the Component for receiving focus
   5167      * events.
   5168      *
   5169      * @param l
   5170      *            the FocusListener.
   5171      */
   5172     public void addFocusListener(FocusListener l) {
   5173         focusListeners.addUserListener(l);
   5174     }
   5175 
   5176     /**
   5177      * Adds the awt focus listener.
   5178      *
   5179      * @param l
   5180      *            the l.
   5181      */
   5182     void addAWTFocusListener(FocusListener l) {
   5183         enableAWTEvents(AWTEvent.FOCUS_EVENT_MASK);
   5184         focusListeners.addSystemListener(l);
   5185     }
   5186 
   5187     /**
   5188      * Removes the focus listener registered for this Component.
   5189      *
   5190      * @param l
   5191      *            the FocusListener.
   5192      */
   5193     public void removeFocusListener(FocusListener l) {
   5194         focusListeners.removeUserListener(l);
   5195     }
   5196 
   5197     /**
   5198      * Processes a FocusEvent that has occurred on this component by dispatching
   5199      * it to the registered listeners.
   5200      *
   5201      * @param e
   5202      *            the FocusEvent.
   5203      */
   5204     protected void processFocusEvent(FocusEvent e) {
   5205         processFocusEventImpl(e, focusListeners.getUserListeners());
   5206     }
   5207 
   5208     /**
   5209      * Process focus event impl.
   5210      *
   5211      * @param e
   5212      *            the e.
   5213      * @param c
   5214      *            the c.
   5215      */
   5216     private void processFocusEventImpl(FocusEvent e, Collection<FocusListener> c) {
   5217         for (FocusListener listener : c) {
   5218             switch (e.getID()) {
   5219                 case FocusEvent.FOCUS_GAINED:
   5220                     listener.focusGained(e);
   5221                     break;
   5222                 case FocusEvent.FOCUS_LOST:
   5223                     listener.focusLost(e);
   5224                     break;
   5225             }
   5226         }
   5227     }
   5228 
   5229     /**
   5230      * Gets an array of registered HierarchyListeners for this Component.
   5231      *
   5232      * @return an array of registered HierarchyListeners for this Component.
   5233      */
   5234     public HierarchyListener[] getHierarchyListeners() {
   5235         return hierarchyListeners.getUserListeners(new HierarchyListener[0]);
   5236     }
   5237 
   5238     /**
   5239      * Adds the specified hierarchy listener.
   5240      *
   5241      * @param l
   5242      *            the HierarchyListener.
   5243      */
   5244     public void addHierarchyListener(HierarchyListener l) {
   5245         hierarchyListeners.addUserListener(l);
   5246     }
   5247 
   5248     /**
   5249      * Removes the hierarchy listener registered for this component.
   5250      *
   5251      * @param l
   5252      *            the HierarchyListener.
   5253      */
   5254     public void removeHierarchyListener(HierarchyListener l) {
   5255         hierarchyListeners.removeUserListener(l);
   5256     }
   5257 
   5258     /**
   5259      * Processes a hierarchy event that has occurred on this component by
   5260      * dispatching it to the registered listeners.
   5261      *
   5262      * @param e
   5263      *            the HierarchyEvent.
   5264      */
   5265     protected void processHierarchyEvent(HierarchyEvent e) {
   5266         for (HierarchyListener listener : hierarchyListeners.getUserListeners()) {
   5267             switch (e.getID()) {
   5268                 case HierarchyEvent.HIERARCHY_CHANGED:
   5269                     listener.hierarchyChanged(e);
   5270                     break;
   5271             }
   5272         }
   5273     }
   5274 
   5275     /**
   5276      * Gets an array of HierarchyBoundsListener objects registered to this
   5277      * Component.
   5278      *
   5279      * @return an array of HierarchyBoundsListener objects.
   5280      */
   5281     public HierarchyBoundsListener[] getHierarchyBoundsListeners() {
   5282         return hierarchyBoundsListeners.getUserListeners(new HierarchyBoundsListener[0]);
   5283     }
   5284 
   5285     /**
   5286      * Adds the specified hierarchy bounds listener.
   5287      *
   5288      * @param l
   5289      *            the HierarchyBoundsListener.
   5290      */
   5291     public void addHierarchyBoundsListener(HierarchyBoundsListener l) {
   5292         hierarchyBoundsListeners.addUserListener(l);
   5293     }
   5294 
   5295     /**
   5296      * Removes the hierarchy bounds listener registered for this Component.
   5297      *
   5298      * @param l
   5299      *            the HierarchyBoundsListener.
   5300      */
   5301     public void removeHierarchyBoundsListener(HierarchyBoundsListener l) {
   5302         hierarchyBoundsListeners.removeUserListener(l);
   5303     }
   5304 
   5305     /**
   5306      * Processes a hierarchy bounds event that has occurred on this component by
   5307      * dispatching it to the registered listeners.
   5308      *
   5309      * @param e
   5310      *            the HierarchyBoundsEvent.
   5311      */
   5312     protected void processHierarchyBoundsEvent(HierarchyEvent e) {
   5313         for (HierarchyBoundsListener listener : hierarchyBoundsListeners.getUserListeners()) {
   5314             switch (e.getID()) {
   5315                 case HierarchyEvent.ANCESTOR_MOVED:
   5316                     listener.ancestorMoved(e);
   5317                     break;
   5318                 case HierarchyEvent.ANCESTOR_RESIZED:
   5319                     listener.ancestorResized(e);
   5320                     break;
   5321             }
   5322         }
   5323     }
   5324 
   5325     /**
   5326      * Gets an array of the key listeners registered to the Component.
   5327      *
   5328      * @return an array of the key listeners registered to the Component.
   5329      */
   5330     public KeyListener[] getKeyListeners() {
   5331         return keyListeners.getUserListeners(new KeyListener[0]);
   5332     }
   5333 
   5334     /**
   5335      * Adds the specified key listener.
   5336      *
   5337      * @param l
   5338      *            the KeyListener.
   5339      */
   5340     public void addKeyListener(KeyListener l) {
   5341         keyListeners.addUserListener(l);
   5342     }
   5343 
   5344     /**
   5345      * Adds the awt key listener.
   5346      *
   5347      * @param l
   5348      *            the l.
   5349      */
   5350     void addAWTKeyListener(KeyListener l) {
   5351         enableAWTEvents(AWTEvent.KEY_EVENT_MASK);
   5352         keyListeners.addSystemListener(l);
   5353     }
   5354 
   5355     /**
   5356      * Removes the key listener registered for this Component.
   5357      *
   5358      * @param l
   5359      *            the KeyListener.
   5360      */
   5361     public void removeKeyListener(KeyListener l) {
   5362         keyListeners.removeUserListener(l);
   5363     }
   5364 
   5365     /**
   5366      * Processes a key event that has occurred on this component by dispatching
   5367      * it to the registered listeners.
   5368      *
   5369      * @param e
   5370      *            the KeyEvent.
   5371      */
   5372     protected void processKeyEvent(KeyEvent e) {
   5373         processKeyEventImpl(e, keyListeners.getUserListeners());
   5374     }
   5375 
   5376     /**
   5377      * Process key event impl.
   5378      *
   5379      * @param e
   5380      *            the e.
   5381      * @param c
   5382      *            the c.
   5383      */
   5384     private void processKeyEventImpl(KeyEvent e, Collection<KeyListener> c) {
   5385         for (KeyListener listener : c) {
   5386             switch (e.getID()) {
   5387                 case KeyEvent.KEY_PRESSED:
   5388                     listener.keyPressed(e);
   5389                     break;
   5390                 case KeyEvent.KEY_RELEASED:
   5391                     listener.keyReleased(e);
   5392                     break;
   5393                 case KeyEvent.KEY_TYPED:
   5394                     listener.keyTyped(e);
   5395                     break;
   5396             }
   5397         }
   5398     }
   5399 
   5400     /**
   5401      * Gets an array of the mouse listeners registered to the Component.
   5402      *
   5403      * @return an array of the mouse listeners registered to the Component.
   5404      */
   5405     public MouseListener[] getMouseListeners() {
   5406         return mouseListeners.getUserListeners(new MouseListener[0]);
   5407     }
   5408 
   5409     /**
   5410      * Adds the specified mouse listener.
   5411      *
   5412      * @param l
   5413      *            the MouseListener.
   5414      */
   5415     public void addMouseListener(MouseListener l) {
   5416         mouseListeners.addUserListener(l);
   5417     }
   5418 
   5419     /**
   5420      * Adds the awt mouse listener.
   5421      *
   5422      * @param l
   5423      *            the l.
   5424      */
   5425     void addAWTMouseListener(MouseListener l) {
   5426         enableAWTEvents(AWTEvent.MOUSE_EVENT_MASK);
   5427         mouseListeners.addSystemListener(l);
   5428     }
   5429 
   5430     /**
   5431      * Adds the awt mouse motion listener.
   5432      *
   5433      * @param l
   5434      *            the l.
   5435      */
   5436     void addAWTMouseMotionListener(MouseMotionListener l) {
   5437         enableAWTEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
   5438         mouseMotionListeners.addSystemListener(l);
   5439     }
   5440 
   5441     /**
   5442      * Adds the awt component listener.
   5443      *
   5444      * @param l
   5445      *            the l.
   5446      */
   5447     void addAWTComponentListener(ComponentListener l) {
   5448         enableAWTEvents(AWTEvent.COMPONENT_EVENT_MASK);
   5449         componentListeners.addSystemListener(l);
   5450     }
   5451 
   5452     /**
   5453      * Adds the awt input method listener.
   5454      *
   5455      * @param l
   5456      *            the l.
   5457      */
   5458     void addAWTInputMethodListener(InputMethodListener l) {
   5459         enableAWTEvents(AWTEvent.INPUT_METHOD_EVENT_MASK);
   5460         inputMethodListeners.addSystemListener(l);
   5461     }
   5462 
   5463     /**
   5464      * Adds the awt mouse wheel listener.
   5465      *
   5466      * @param l
   5467      *            the l.
   5468      */
   5469     void addAWTMouseWheelListener(MouseWheelListener l) {
   5470         enableAWTEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
   5471         mouseWheelListeners.addSystemListener(l);
   5472     }
   5473 
   5474     /**
   5475      * Removes the mouse listener registered for this Component.
   5476      *
   5477      * @param l
   5478      *            the MouseListener.
   5479      */
   5480     public void removeMouseListener(MouseListener l) {
   5481         mouseListeners.removeUserListener(l);
   5482     }
   5483 
   5484     /**
   5485      * Processes a mouse event that has occurred on this component by
   5486      * dispatching it to the registered listeners.
   5487      *
   5488      * @param e
   5489      *            the MouseEvent.
   5490      */
   5491     protected void processMouseEvent(MouseEvent e) {
   5492         processMouseEventImpl(e, mouseListeners.getUserListeners());
   5493     }
   5494 
   5495     /**
   5496      * Process mouse event impl.
   5497      *
   5498      * @param e
   5499      *            the e.
   5500      * @param c
   5501      *            the c.
   5502      */
   5503     private void processMouseEventImpl(MouseEvent e, Collection<MouseListener> c) {
   5504         for (MouseListener listener : c) {
   5505             switch (e.getID()) {
   5506                 case MouseEvent.MOUSE_CLICKED:
   5507                     listener.mouseClicked(e);
   5508                     break;
   5509                 case MouseEvent.MOUSE_ENTERED:
   5510                     listener.mouseEntered(e);
   5511                     break;
   5512                 case MouseEvent.MOUSE_EXITED:
   5513                     listener.mouseExited(e);
   5514                     break;
   5515                 case MouseEvent.MOUSE_PRESSED:
   5516                     listener.mousePressed(e);
   5517                     break;
   5518                 case MouseEvent.MOUSE_RELEASED:
   5519                     listener.mouseReleased(e);
   5520                     break;
   5521             }
   5522         }
   5523     }
   5524 
   5525     /**
   5526      * Process mouse motion event impl.
   5527      *
   5528      * @param e
   5529      *            the e.
   5530      * @param c
   5531      *            the c.
   5532      */
   5533     private void processMouseMotionEventImpl(MouseEvent e, Collection<MouseMotionListener> c) {
   5534         for (MouseMotionListener listener : c) {
   5535             switch (e.getID()) {
   5536                 case MouseEvent.MOUSE_DRAGGED:
   5537                     listener.mouseDragged(e);
   5538                     break;
   5539                 case MouseEvent.MOUSE_MOVED:
   5540                     listener.mouseMoved(e);
   5541                     break;
   5542             }
   5543         }
   5544     }
   5545 
   5546     /**
   5547      * Gets an array of the mouse motion listeners registered to the Component.
   5548      *
   5549      * @return an array of the MouseMotionListeners registered to the Component.
   5550      */
   5551     public MouseMotionListener[] getMouseMotionListeners() {
   5552         return mouseMotionListeners.getUserListeners(new MouseMotionListener[0]);
   5553     }
   5554 
   5555     /**
   5556      * Adds the specified mouse motion listener.
   5557      *
   5558      * @param l
   5559      *            the MouseMotionListener.
   5560      */
   5561     public void addMouseMotionListener(MouseMotionListener l) {
   5562         mouseMotionListeners.addUserListener(l);
   5563     }
   5564 
   5565     /**
   5566      * Removes the mouse motion listener registered for this component.
   5567      *
   5568      * @param l
   5569      *            the MouseMotionListener.
   5570      */
   5571     public void removeMouseMotionListener(MouseMotionListener l) {
   5572         mouseMotionListeners.removeUserListener(l);
   5573     }
   5574 
   5575     /**
   5576      * Processes a mouse motion event that has occurred on this component by
   5577      * dispatching it to the registered listeners.
   5578      *
   5579      * @param e
   5580      *            the MouseEvent.
   5581      */
   5582     protected void processMouseMotionEvent(MouseEvent e) {
   5583         processMouseMotionEventImpl(e, mouseMotionListeners.getUserListeners());
   5584     }
   5585 
   5586     /**
   5587      * Gets an array of the mouse wheel listeners registered to the Component.
   5588      *
   5589      * @return an array of the MouseWheelListeners registered to the Component.
   5590      */
   5591     public MouseWheelListener[] getMouseWheelListeners() {
   5592         return mouseWheelListeners.getUserListeners(new MouseWheelListener[0]);
   5593     }
   5594 
   5595     /**
   5596      * Adds the specified mouse wheel listener.
   5597      *
   5598      * @param l
   5599      *            the MouseWheelListener.
   5600      */
   5601     public void addMouseWheelListener(MouseWheelListener l) {
   5602         mouseWheelListeners.addUserListener(l);
   5603     }
   5604 
   5605     /**
   5606      * Removes the mouse wheel listener registered for this component.
   5607      *
   5608      * @param l
   5609      *            the MouseWheelListener.
   5610      */
   5611     public void removeMouseWheelListener(MouseWheelListener l) {
   5612         mouseWheelListeners.removeUserListener(l);
   5613     }
   5614 
   5615     /**
   5616      * Processes a mouse wheel event that has occurred on this component by
   5617      * dispatching it to the registered listeners.
   5618      *
   5619      * @param e
   5620      *            the MouseWheelEvent.
   5621      */
   5622     protected void processMouseWheelEvent(MouseWheelEvent e) {
   5623         processMouseWheelEventImpl(e, mouseWheelListeners.getUserListeners());
   5624     }
   5625 
   5626     /**
   5627      * Gets an array of the InputMethodListener listeners registered to the
   5628      * Component.
   5629      *
   5630      * @return an array of the InputMethodListener listeners registered to the
   5631      *         Component.
   5632      */
   5633     public InputMethodListener[] getInputMethodListeners() {
   5634         return inputMethodListeners.getUserListeners(new InputMethodListener[0]);
   5635     }
   5636 
   5637     /**
   5638      * Adds the specified input method listener.
   5639      *
   5640      * @param l
   5641      *            the InputMethodListener.
   5642      */
   5643     public void addInputMethodListener(InputMethodListener l) {
   5644         inputMethodListeners.addUserListener(l);
   5645     }
   5646 
   5647     /**
   5648      * Removes the input method listener registered for this component.
   5649      *
   5650      * @param l
   5651      *            the InputMethodListener.
   5652      */
   5653     public void removeInputMethodListener(InputMethodListener l) {
   5654         inputMethodListeners.removeUserListener(l);
   5655     }
   5656 
   5657     /**
   5658      * Processes an input method event that has occurred on this component by
   5659      * dispatching it to the registered listeners.
   5660      *
   5661      * @param e
   5662      *            the InputMethodEvent.
   5663      */
   5664     protected void processInputMethodEvent(InputMethodEvent e) {
   5665         processInputMethodEventImpl(e, inputMethodListeners.getUserListeners());
   5666     }
   5667 
   5668     /**
   5669      * Process input method event impl.
   5670      *
   5671      * @param e
   5672      *            the e.
   5673      * @param c
   5674      *            the c.
   5675      */
   5676     private void processInputMethodEventImpl(InputMethodEvent e, Collection<InputMethodListener> c) {
   5677         for (InputMethodListener listener : c) {
   5678             switch (e.getID()) {
   5679                 case InputMethodEvent.CARET_POSITION_CHANGED:
   5680                     listener.caretPositionChanged(e);
   5681                     break;
   5682                 case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
   5683                     listener.inputMethodTextChanged(e);
   5684                     break;
   5685             }
   5686         }
   5687     }
   5688 
   5689     // ???AWT
   5690     /*
   5691      * public Point getMousePosition() throws HeadlessException { Point
   5692      * absPointerPos = MouseInfo.getPointerInfo().getLocation(); Window
   5693      * winUnderPtr =
   5694      * toolkit.dispatcher.mouseDispatcher.findWindowAt(absPointerPos); Point
   5695      * pointerPos = MouseDispatcher.convertPoint(null, absPointerPos,
   5696      * winUnderPtr); boolean isUnderPointer = false; if (winUnderPtr == null) {
   5697      * return null; } isUnderPointer = winUnderPtr.isComponentAt(this,
   5698      * pointerPos); if (isUnderPointer) { return
   5699      * MouseDispatcher.convertPoint(null, absPointerPos, this); } return null; }
   5700      */
   5701 
   5702     /**
   5703      * Set native caret at the given position <br>
   5704      * Note: this method takes AWT lock inside because it walks through the
   5705      * component hierarchy.
   5706      *
   5707      * @param x
   5708      *            the x.
   5709      * @param y
   5710      *            the y.
   5711      */
   5712     void setCaretPos(final int x, final int y) {
   5713         Runnable r = new Runnable() {
   5714             public void run() {
   5715                 toolkit.lockAWT();
   5716                 try {
   5717                     setCaretPosImpl(x, y);
   5718                 } finally {
   5719                     toolkit.unlockAWT();
   5720                 }
   5721             }
   5722         };
   5723         if (Thread.currentThread() instanceof EventDispatchThread) {
   5724             r.run();
   5725         } else {
   5726             toolkit.getSystemEventQueueImpl().postEvent(new InvocationEvent(this, r));
   5727         }
   5728     }
   5729 
   5730     /**
   5731      * This method should be called only at event dispatch thread.
   5732      *
   5733      * @param x
   5734      *            the x.
   5735      * @param y
   5736      *            the y.
   5737      */
   5738     void setCaretPosImpl(int x, int y) {
   5739         Component c = this;
   5740         while ((c != null) && c.behaviour.isLightweight()) {
   5741             x += c.x;
   5742             y += c.y;
   5743             // ???AWT: c = c.getParent();
   5744         }
   5745         if (c == null) {
   5746             return;
   5747         }
   5748         // ???AWT
   5749         /*
   5750          * if (c instanceof Window) { Insets insets = c.getNativeInsets(); x -=
   5751          * insets.left; y -= insets.top; }
   5752          * toolkit.getWindowFactory().setCaretPosition(x, y);
   5753          */
   5754     }
   5755 
   5756     // to be overridden in standard components such as Button and List
   5757     /**
   5758      * Gets the default minimum size.
   5759      *
   5760      * @return the default minimum size.
   5761      */
   5762     Dimension getDefaultMinimumSize() {
   5763         return null;
   5764     }
   5765 
   5766     // to be overridden in standard components such as Button and List
   5767     /**
   5768      * Gets the default preferred size.
   5769      *
   5770      * @return the default preferred size.
   5771      */
   5772     Dimension getDefaultPreferredSize() {
   5773         return null;
   5774     }
   5775 
   5776     // to be overridden in standard components such as Button and List
   5777     /**
   5778      * Reset default size.
   5779      */
   5780     void resetDefaultSize() {
   5781     }
   5782 
   5783     // ???AWT
   5784     /*
   5785      * ComponentBehavior createBehavior() { return new LWBehavior(this); }
   5786      */
   5787 
   5788     /**
   5789      * Gets the default background.
   5790      *
   5791      * @return the default background.
   5792      */
   5793     Color getDefaultBackground() {
   5794         // ???AWT: return getWindowAncestor().getDefaultBackground();
   5795         return getBackground();
   5796     }
   5797 
   5798     /**
   5799      * Gets the default foreground.
   5800      *
   5801      * @return the default foreground.
   5802      */
   5803     Color getDefaultForeground() {
   5804         // ???AWT return getWindowAncestor().getDefaultForeground();
   5805         return getForeground();
   5806     }
   5807 
   5808     /**
   5809      * Called when native resource for this component is created (for
   5810      * heavyweights only).
   5811      *
   5812      * @param win
   5813      *            the win.
   5814      */
   5815     void nativeWindowCreated(NativeWindow win) {
   5816         // to be overridden
   5817     }
   5818 
   5819     /**
   5820      * Determine the component's area hidden behind the windows that have higher
   5821      * Z-order, including windows of other applications.
   5822      *
   5823      * @param image
   5824      *            the image.
   5825      * @param destLocation
   5826      *            the dest location.
   5827      * @param destSize
   5828      *            the dest size.
   5829      * @param source
   5830      *            the source.
   5831      * @return the calculated region, or null if it cannot be determined.
   5832      */
   5833     // ???AWT
   5834     /*
   5835      * MultiRectArea getObscuredRegion(Rectangle part) { if (!visible || parent
   5836      * == null || !parent.visible) { return null; } Rectangle r = new
   5837      * Rectangle(0, 0, w, h); if (part != null) { r = r.intersection(part); } if
   5838      * (r.isEmpty()) { return null; } r.translate(x, y); MultiRectArea ret =
   5839      * parent.getObscuredRegion(r); if (ret != null) {
   5840      * parent.addObscuredRegions(ret, this); ret.translate(-x, -y);
   5841      * ret.intersect(new Rectangle(0, 0, w, h)); } return ret; }
   5842      */
   5843 
   5844     // ???AWT
   5845     /*
   5846      * private void readObject(ObjectInputStream stream) throws IOException,
   5847      * ClassNotFoundException { stream.defaultReadObject(); FieldsAccessor
   5848      * accessor = new FieldsAccessor(Component.class, this);
   5849      * accessor.set("toolkit", Toolkit.getDefaultToolkit()); //$NON-NLS-1$
   5850      * accessor.set("behaviour", createBehavior()); //$NON-NLS-1$
   5851      * accessor.set("componentLock", new Object()); // $NON-LOCK-1$
   5852      * //$NON-NLS-1$ }
   5853      */
   5854 
   5855     final void onDrawImage(Image image, Point destLocation, Dimension destSize, Rectangle source) {
   5856         ImageParameters imageParams;
   5857         if (updatedImages == null) {
   5858             updatedImages = new HashMap<Image, ImageParameters>();
   5859         }
   5860         imageParams = updatedImages.get(image);
   5861         if (imageParams == null) {
   5862             imageParams = new ImageParameters();
   5863             updatedImages.put(image, imageParams);
   5864         }
   5865         imageParams.addDrawing(destLocation, destSize, source);
   5866     }
   5867 
   5868     public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
   5869         toolkit.lockAWT();
   5870         try {
   5871             boolean done = false;
   5872             if ((infoflags & (ALLBITS | FRAMEBITS)) != 0) {
   5873                 done = true;
   5874             } else if ((infoflags & SOMEBITS) != 0 && incrementalImageUpdate) {
   5875                 done = true;
   5876             }
   5877             if (done) {
   5878                 repaint();
   5879             }
   5880             return (infoflags & (ABORT | ALLBITS)) == 0;
   5881         } finally {
   5882             toolkit.unlockAWT();
   5883         }
   5884     }
   5885 
   5886     // ???AWT
   5887     /*
   5888      * private void invalidateRealParent() { Container realParent =
   5889      * getRealParent(); if ((realParent != null) && realParent.isValid()) {
   5890      * realParent.invalidate(); } }
   5891      */
   5892 
   5893     /**
   5894      * The Class ImageParameters.
   5895      */
   5896     private class ImageParameters {
   5897 
   5898         /**
   5899          * The drawing params.
   5900          */
   5901         private final LinkedList<DrawingParameters> drawingParams = new LinkedList<DrawingParameters>();
   5902 
   5903         /**
   5904          * The size.
   5905          */
   5906         Dimension size = new Dimension(Component.this.w, Component.this.h);
   5907 
   5908         /**
   5909          * Adds the drawing.
   5910          *
   5911          * @param destLocation
   5912          *            the dest location.
   5913          * @param destSize
   5914          *            the dest size.
   5915          * @param source
   5916          *            the source.
   5917          */
   5918         void addDrawing(Point destLocation, Dimension destSize, Rectangle source) {
   5919             drawingParams.add(new DrawingParameters(destLocation, destSize, source));
   5920         }
   5921 
   5922         /**
   5923          * Drawing parameters iterator.
   5924          *
   5925          * @return the iterator< drawing parameters>.
   5926          */
   5927         Iterator<DrawingParameters> drawingParametersIterator() {
   5928             return drawingParams.iterator();
   5929         }
   5930 
   5931         /**
   5932          * The Class DrawingParameters.
   5933          */
   5934         class DrawingParameters {
   5935 
   5936             /**
   5937              * The dest location.
   5938              */
   5939             Point destLocation;
   5940 
   5941             /**
   5942              * The dest size.
   5943              */
   5944             Dimension destSize;
   5945 
   5946             /**
   5947              * The source.
   5948              */
   5949             Rectangle source;
   5950 
   5951             /**
   5952              * Instantiates a new drawing parameters.
   5953              *
   5954              * @param destLocation
   5955              *            the dest location.
   5956              * @param destSize
   5957              *            the dest size.
   5958              * @param source
   5959              *            the source.
   5960              */
   5961             DrawingParameters(Point destLocation, Dimension destSize, Rectangle source) {
   5962                 this.destLocation = new Point(destLocation);
   5963                 if (destSize != null) {
   5964                     this.destSize = new Dimension(destSize);
   5965                 } else {
   5966                     this.destSize = null;
   5967                 }
   5968                 if (source != null) {
   5969                     this.source = new Rectangle(source);
   5970                 } else {
   5971                     this.source = null;
   5972                 }
   5973             }
   5974         }
   5975     }
   5976 
   5977     /**
   5978      * TextComponent support.
   5979      *
   5980      * @param e
   5981      *            the e.
   5982      * @return true, if dispatch event to im.
   5983      */
   5984     // ???AWT
   5985     /*
   5986      * private TextKit textKit = null; TextKit getTextKit() { return textKit; }
   5987      * void setTextKit(TextKit kit) { textKit = kit; }
   5988      */
   5989 
   5990     /**
   5991      * TextField support.
   5992      */
   5993     // ???AWT
   5994     /*
   5995      * private TextFieldKit textFieldKit = null; TextFieldKit getTextFieldKit()
   5996      * { return textFieldKit; } void setTextFieldKit(TextFieldKit kit) {
   5997      * textFieldKit = kit; }
   5998      */
   5999 
   6000     /**
   6001      * Dispatches input & focus events to input method context.
   6002      *
   6003      * @param e
   6004      *            event to pass to InputContext.dispatchEvent().
   6005      * @return true if event was consumed by IM, false otherwise.
   6006      */
   6007     private boolean dispatchEventToIM(AWTEvent e) {
   6008         InputContext ic = getInputContext();
   6009         if (ic == null) {
   6010             return false;
   6011         }
   6012         int id = e.getID();
   6013         boolean isInputEvent = ((id >= KeyEvent.KEY_FIRST) && (id <= KeyEvent.KEY_LAST))
   6014                 || ((id >= MouseEvent.MOUSE_FIRST) && (id <= MouseEvent.MOUSE_LAST));
   6015         if (((id >= FocusEvent.FOCUS_FIRST) && (id <= FocusEvent.FOCUS_LAST)) || isInputEvent) {
   6016             ic.dispatchEvent(e);
   6017         }
   6018         return e.isConsumed();
   6019     }
   6020 }
   6021