1 /*
   2  * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import sun.misc.Unsafe;
  29 
  30 import javax.accessibility.AccessibleContext;
  31 import java.awt.*;
  32 import java.awt.KeyboardFocusManager;
  33 import java.awt.DefaultKeyboardFocusManager;
  34 import java.awt.event.InputEvent;
  35 import java.awt.event.InvocationEvent;
  36 import java.awt.event.KeyEvent;
  37 import java.awt.geom.Point2D;
  38 import java.awt.peer.ComponentPeer;
  39 import java.awt.peer.MenuComponentPeer;
  40 
  41 import java.lang.reflect.InvocationTargetException;
  42 import java.security.AccessControlContext;
  43 
  44 import java.io.File;
  45 import java.util.ResourceBundle;
  46 import java.util.Vector;
  47 
  48 /**
  49  * The AWTAccessor utility class.
  50  * The main purpose of this class is to enable accessing
  51  * private and package-private fields of classes from
  52  * different classes/packages. See sun.misc.SharedSecretes
  53  * for another example.
  54  */
  55 public final class AWTAccessor {
  56 
  57     private static final Unsafe unsafe = Unsafe.getUnsafe();
  58 
  59     /*
  60      * We don't need any objects of this class.
  61      * It's rather a collection of static methods
  62      * and interfaces.
  63      */
  64     private AWTAccessor() {
  65     }
  66 
  67     /*
  68      * An interface of accessor for the java.awt.Component class.
  69      */
  70     public interface ComponentAccessor {
  71         /*
  72          * Sets whether the native background erase for a component
  73          * has been disabled via SunToolkit.disableBackgroundErase().
  74          */
  75         void setBackgroundEraseDisabled(Component comp, boolean disabled);
  76         /*
  77          * Indicates whether the native background erase for a
  78          * component has been disabled via
  79          * SunToolkit.disableBackgroundErase().
  80          */
  81         boolean getBackgroundEraseDisabled(Component comp);
  82         /*
  83          *
  84          * Gets the bounds of this component in the form of a
  85          * <code>Rectangle</code> object. The bounds specify this
  86          * component's width, height, and location relative to
  87          * its parent.
  88          */
  89         Rectangle getBounds(Component comp);
  90         /*
  91          * Sets the shape of a lw component to cut out from hw components.
  92          *
  93          * See 6797587, 6776743, 6768307, and 6768332 for details
  94          */
  95         void setMixingCutoutShape(Component comp, Shape shape);
  96 
  97         /**
  98          * Sets GraphicsConfiguration value for the component.
  99          */
 100         void setGraphicsConfiguration(Component comp, GraphicsConfiguration gc);
 101         /*
 102          * Requests focus to the component.
 103          */
 104         boolean requestFocus(Component comp, CausedFocusEvent.Cause cause);
 105         /*
 106          * Determines if the component can gain focus.
 107          */
 108         boolean canBeFocusOwner(Component comp);
 109 
 110         /**
 111          * Returns whether the component is visible without invoking
 112          * any client code.
 113          */
 114         boolean isVisible(Component comp);
 115 
 116         /**
 117          * Sets the RequestFocusController.
 118          */
 119         void setRequestFocusController(RequestFocusController requestController);
 120 
 121         /**
 122          * Returns the appContext of the component.
 123          */
 124         AppContext getAppContext(Component comp);
 125 
 126         /**
 127          * Sets the appContext of the component.
 128          */
 129         void setAppContext(Component comp, AppContext appContext);
 130 
 131         /**
 132          * Returns the parent of the component.
 133          */
 134         Container getParent(Component comp);
 135 
 136         /**
 137          * Sets the parent of the component to the specified parent.
 138          */
 139         void setParent(Component comp, Container parent);
 140 
 141         /**
 142          * Resizes the component to the specified width and height.
 143          */
 144         void setSize(Component comp, int width, int height);
 145 
 146         /**
 147          * Returns the location of the component.
 148          */
 149         Point getLocation(Component comp);
 150 
 151         /**
 152          * Moves the component to the new location.
 153          */
 154         void setLocation(Component comp, int x, int y);
 155 
 156         /**
 157          * Determines whether this component is enabled.
 158          */
 159         boolean isEnabled(Component comp);
 160 
 161         /**
 162          * Determines whether this component is displayable.
 163          */
 164         boolean isDisplayable(Component comp);
 165 
 166         /**
 167          * Gets the cursor set in the component.
 168          */
 169         Cursor getCursor(Component comp);
 170 
 171         /**
 172          * Returns the peer of the component.
 173          */
 174         ComponentPeer getPeer(Component comp);
 175 
 176         /**
 177          * Sets the peer of the component to the specified peer.
 178          */
 179         void setPeer(Component comp, ComponentPeer peer);
 180 
 181         /**
 182          * Determines whether this component is lightweight.
 183          */
 184         boolean isLightweight(Component comp);
 185 
 186         /**
 187          * Returns whether or not paint messages received from
 188          * the operating system should be ignored.
 189          */
 190         boolean getIgnoreRepaint(Component comp);
 191 
 192         /**
 193          * Returns the width of the component.
 194          */
 195         int getWidth(Component comp);
 196 
 197         /**
 198          * Returns the height of the component.
 199          */
 200         int getHeight(Component comp);
 201 
 202         /**
 203          * Returns the x coordinate of the component.
 204          */
 205         int getX(Component comp);
 206 
 207         /**
 208          * Returns the y coordinate of the component.
 209          */
 210         int getY(Component comp);
 211 
 212         /**
 213          * Gets the foreground color of this component.
 214          */
 215         Color getForeground(Component comp);
 216 
 217         /**
 218          * Gets the background color of this component.
 219          */
 220         Color getBackground(Component comp);
 221 
 222         /**
 223          * Sets the background of this component to the specified color.
 224          */
 225         void setBackground(Component comp, Color background);
 226 
 227         /**
 228          * Gets the font of the component.
 229          */
 230         Font getFont(Component comp);
 231 
 232         /**
 233          * Processes events occurring on this component.
 234          */
 235         void processEvent(Component comp, AWTEvent e);
 236 
 237 
 238         /*
 239          * Returns the acc this component was constructed with.
 240          */
 241         AccessControlContext getAccessControlContext(Component comp);
 242 
 243         /**
 244          * Revalidates the component synchronously.
 245          */
 246         void revalidateSynchronously(Component comp);
 247 
 248     }
 249 
 250     /*
 251      * An interface of accessor for the java.awt.Container class.
 252      */
 253     public interface ContainerAccessor {
 254         /**
 255          * Validates the container unconditionally.
 256          */
 257         void validateUnconditionally(Container cont);
 258 
 259         /**
 260          *
 261          * Access to the private version of findComponentAt method which has
 262          * a controllable behavior. Setting 'ignoreEnabled' to 'false'
 263          * bypasses disabled Components during the search.
 264          */
 265         Component findComponentAt(Container cont, int x, int y, boolean ignoreEnabled);
 266     }
 267 
 268     /*
 269      * An interface of accessor for java.awt.Window class.
 270      */
 271     public interface WindowAccessor {
 272         /*
 273          * Get opacity level of the given window.
 274          */
 275         float getOpacity(Window window);
 276         /*
 277          * Set opacity level to the given window.
 278          */
 279         void setOpacity(Window window, float opacity);
 280         /*
 281          * Get a shape assigned to the given window.
 282          */
 283         Shape getShape(Window window);
 284         /*
 285          * Set a shape to the given window.
 286          */
 287         void setShape(Window window, Shape shape);
 288         /*
 289          * Set the opaque preoperty to the given window.
 290          */
 291         void setOpaque(Window window, boolean isOpaque);
 292         /*
 293          * Update the image of a non-opaque (translucent) window.
 294          */
 295         void updateWindow(Window window);
 296 
 297         /** Get the size of the security warning.
 298          */
 299         Dimension getSecurityWarningSize(Window w);
 300 
 301         /**
 302          * Set the size of the security warning.
 303          */
 304         void setSecurityWarningSize(Window w, int width, int height);
 305 
 306         /** Set the position of the security warning.
 307          */
 308         void setSecurityWarningPosition(Window w, Point2D point,
 309                 float alignmentX, float alignmentY);
 310 
 311         /** Request to recalculate the new position of the security warning for
 312          * the given window size/location as reported by the native system.
 313          */
 314         Point2D calculateSecurityWarningPosition(Window window,
 315                 double x, double y, double w, double h);
 316 
 317         /** Sets the synchronous status of focus requests on lightweight
 318          * components in the specified window to the specified value.
 319          */
 320         void setLWRequestStatus(Window changed, boolean status);
 321 
 322         /**
 323          * Indicates whether this window should receive focus on subsequently
 324          * being shown, or being moved to the front.
 325          */
 326         boolean isAutoRequestFocus(Window w);
 327 
 328         /**
 329          * Indicates whether the specified window is an utility window for TrayIcon.
 330          */
 331         boolean isTrayIconWindow(Window w);
 332 
 333         /**
 334          * Marks the specified window as an utility window for TrayIcon.
 335          */
 336         void setTrayIconWindow(Window w, boolean isTrayIconWindow);
 337 
 338         /**
 339          * Return an array containing all the windows this
 340          * window currently owns.
 341          */
 342         Window[] getOwnedWindows(Window w);
 343     }
 344 
 345     /**
 346      * An accessor for the AWTEvent class.
 347      */
 348     public interface AWTEventAccessor {
 349         /**
 350          * Marks the event as posted.
 351          */
 352         void setPosted(AWTEvent ev);
 353 
 354         /**
 355          * Sets the flag on this AWTEvent indicating that it was
 356          * generated by the system.
 357          */
 358         void setSystemGenerated(AWTEvent ev);
 359 
 360         /**
 361          * Indicates whether this AWTEvent was generated by the system.
 362          */
 363         boolean isSystemGenerated(AWTEvent ev);
 364 
 365         /**
 366          * Returns the acc this event was constructed with.
 367          */
 368         AccessControlContext getAccessControlContext(AWTEvent ev);
 369 
 370         /**
 371          * Returns binary data associated with this event;
 372          */
 373         byte[] getBData(AWTEvent ev);
 374 
 375         /**
 376          * Associates binary data with this event;
 377          */
 378         void setBData(AWTEvent ev, byte[] bdata);
 379     }
 380 
 381     public interface InputEventAccessor {
 382         /*
 383          * Accessor for InputEvent.getButtonDownMasks()
 384          */
 385         int[] getButtonDownMasks();
 386     }
 387 
 388     /*
 389      * An accessor for the java.awt.Frame class.
 390      */
 391     public interface FrameAccessor {
 392         /*
 393          * Sets the state of this frame.
 394          */
 395         void setExtendedState(Frame frame, int state);
 396         /*
 397          * Gets the state of this frame.
 398          */
 399        int getExtendedState(Frame frame);
 400         /*
 401          * Gets the maximized bounds of this frame.
 402          */
 403        Rectangle getMaximizedBounds(Frame frame);
 404     }
 405 
 406     /**
 407      * An interface of accessor for the java.awt.KeyboardFocusManager class.
 408      */
 409     public interface KeyboardFocusManagerAccessor {
 410         /**
 411          * Indicates whether the native implementation should
 412          * proceed with a pending focus request for the heavyweight.
 413          */
 414         int shouldNativelyFocusHeavyweight(Component heavyweight,
 415                                            Component descendant,
 416                                            boolean temporary,
 417                                            boolean focusedWindowChangeAllowed,
 418                                            long time,
 419                                            CausedFocusEvent.Cause cause);
 420         /**
 421          * Delivers focus for the lightweight descendant of the heavyweight
 422          * synchronously.
 423          */
 424         boolean processSynchronousLightweightTransfer(Component heavyweight,
 425                                                       Component descendant,
 426                                                       boolean temporary,
 427                                                       boolean focusedWindowChangeAllowed,
 428                                                       long time);
 429         /**
 430          * Removes the last focus request for the heavyweight from the queue.
 431          */
 432         void removeLastFocusRequest(Component heavyweight);
 433 
 434         /**
 435          * Sets the most recent focus owner in the window.
 436          */
 437         void setMostRecentFocusOwner(Window window, Component component);
 438 
 439         /**
 440          * Returns current KFM of the specified AppContext.
 441          */
 442         KeyboardFocusManager getCurrentKeyboardFocusManager(AppContext ctx);
 443 
 444         /**
 445          * Return the current focus cycle root
 446          */
 447         Container getCurrentFocusCycleRoot();
 448     }
 449 
 450     /**
 451      * An accessor for the MenuComponent class.
 452      */
 453     public interface MenuComponentAccessor {
 454         /**
 455          * Returns the appContext of the menu component.
 456          */
 457         AppContext getAppContext(MenuComponent menuComp);
 458 
 459         /**
 460          * Sets the appContext of the menu component.
 461          */
 462         void setAppContext(MenuComponent menuComp, AppContext appContext);
 463 
 464         /**
 465          * Returns the menu container of the menu component
 466          */
 467         MenuContainer getParent(MenuComponent menuComp);
 468 
 469         /**
 470          * Gets the font used for this menu component.
 471          */
 472         Font getFont_NoClientCode(MenuComponent menuComp);
 473 
 474         /**
 475          * Returns the peer of the menu component.
 476          */
 477         <T extends MenuComponentPeer> T getPeer(MenuComponent menuComp);
 478     }
 479 
 480     /**
 481      * An accessor for the EventQueue class
 482      */
 483     public interface EventQueueAccessor {
 484         /**
 485          * Gets the event dispatch thread.
 486          */
 487         Thread getDispatchThread(EventQueue eventQueue);
 488 
 489         /**
 490          * Checks if the current thread is EDT for the given EQ.
 491          */
 492         public boolean isDispatchThreadImpl(EventQueue eventQueue);
 493 
 494         /**
 495          * Removes any pending events for the specified source object.
 496          */
 497         void removeSourceEvents(EventQueue eventQueue, Object source, boolean removeAllEvents);
 498 
 499         /**
 500          * Returns whether an event is pending on any of the separate Queues.
 501          */
 502         boolean noEvents(EventQueue eventQueue);
 503 
 504         /**
 505          * Called from PostEventQueue.postEvent to notify that a new event
 506          * appeared.
 507          */
 508         void wakeup(EventQueue eventQueue, boolean isShutdown);
 509 
 510         /**
 511          * Static in EventQueue
 512          */
 513         void invokeAndWait(Object source, Runnable r)
 514             throws InterruptedException, InvocationTargetException;
 515 
 516         /**
 517          * Sets the delegate for the EventQueue used by FX/AWT single threaded mode
 518          */
 519         void setFwDispatcher(EventQueue eventQueue, FwDispatcher dispatcher);
 520 
 521         /**
 522          * Gets most recent event time in the EventQueue
 523          */
 524         long getMostRecentEventTime(EventQueue eventQueue);
 525     }
 526 
 527     /*
 528      * An accessor for the PopupMenu class
 529      */
 530     public interface PopupMenuAccessor {
 531         /*
 532          * Returns whether the popup menu is attached to a tray
 533          */
 534         boolean isTrayIconPopup(PopupMenu popupMenu);
 535     }
 536 
 537     /*
 538      * An accessor for the FileDialog class
 539      */
 540     public interface FileDialogAccessor {
 541         /*
 542          * Sets the files the user selects
 543          */
 544         void setFiles(FileDialog fileDialog, File files[]);
 545 
 546         /*
 547          * Sets the file the user selects
 548          */
 549         void setFile(FileDialog fileDialog, String file);
 550 
 551         /*
 552          * Sets the directory the user selects
 553          */
 554         void setDirectory(FileDialog fileDialog, String directory);
 555 
 556         /*
 557          * Returns whether the file dialog allows the multiple file selection.
 558          */
 559         boolean isMultipleMode(FileDialog fileDialog);
 560     }
 561 
 562     /*
 563      * An accessor for the ScrollPaneAdjustable class.
 564      */
 565     public interface ScrollPaneAdjustableAccessor {
 566         /*
 567          * Sets the value of this scrollbar to the specified value.
 568          */
 569         void setTypedValue(final ScrollPaneAdjustable adj, final int v,
 570                            final int type);
 571     }
 572 
 573     /**
 574      * An accessor for the CheckboxMenuItem class
 575      */
 576     public interface CheckboxMenuItemAccessor {
 577         /**
 578          * Returns whether menu item is checked
 579          */
 580         boolean getState(CheckboxMenuItem cmi);
 581     }
 582 
 583     /**
 584      * An accessor for the Cursor class
 585      */
 586     public interface CursorAccessor {
 587         /**
 588          * Returns pData of the Cursor class
 589          */
 590         long getPData(Cursor cursor);
 591 
 592         /**
 593          * Sets pData to the Cursor class
 594          */
 595         void setPData(Cursor cursor, long pData);
 596 
 597         /**
 598          * Return type of the Cursor class
 599          */
 600         int getType(Cursor cursor);
 601     }
 602 
 603     /**
 604      * An accessor for the MenuBar class
 605      */
 606     public interface MenuBarAccessor {
 607         /**
 608          * Returns help menu
 609          */
 610         Menu getHelpMenu(MenuBar menuBar);
 611 
 612         /**
 613          * Returns menus
 614          */
 615         Vector getMenus(MenuBar menuBar);
 616     }
 617 
 618     /**
 619      * An accessor for the MenuItem class
 620      */
 621     public interface MenuItemAccessor {
 622         /**
 623          * Returns whether menu item is enabled
 624          */
 625         boolean isEnabled(MenuItem item);
 626 
 627         /**
 628          * Gets the command name of the action event that is fired
 629          * by this menu item.
 630          */
 631         String getActionCommandImpl(MenuItem item);
 632 
 633         /**
 634          * Returns true if the item and all its ancestors are
 635          * enabled, false otherwise
 636          */
 637         boolean isItemEnabled(MenuItem item);
 638 
 639         /**
 640          * Returns label
 641          */
 642         String getLabel(MenuItem item);
 643 
 644         /**
 645          * Returns shortcut
 646          */
 647         MenuShortcut getShortcut(MenuItem item);
 648     }
 649 
 650     /**
 651      * An accessor for the Menu class
 652      */
 653     public interface MenuAccessor {
 654         /**
 655          * Returns vector of the items that are part of the Menu
 656          */
 657         Vector getItems(Menu menu);
 658     }
 659 
 660     /**
 661      * An accessor for the KeyEvent class
 662      */
 663     public interface KeyEventAccessor {
 664         /**
 665          * Sets rawCode field for KeyEvent
 666          */
 667         void setRawCode(KeyEvent ev, long rawCode);
 668 
 669         /**
 670          * Sets primaryLevelUnicode field for KeyEvent
 671          */
 672         void setPrimaryLevelUnicode(KeyEvent ev, long primaryLevelUnicode);
 673 
 674         /**
 675          * Sets extendedKeyCode field for KeyEvent
 676          */
 677         void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode);
 678 
 679         /**
 680          * Gets original source for KeyEvent
 681          */
 682         Component getOriginalSource(KeyEvent ev);
 683     }
 684 
 685     /**
 686      * An accessor for the ClientPropertyKey class
 687      */
 688     public interface ClientPropertyKeyAccessor {
 689         /**
 690          * Retrieves JComponent_TRANSFER_HANDLER enum object
 691          */
 692         Object getJComponent_TRANSFER_HANDLER();
 693     }
 694 
 695     /**
 696      * An accessor for the SystemTray class
 697      */
 698     public interface SystemTrayAccessor {
 699         /**
 700          * Support for reporting bound property changes for Object properties.
 701          */
 702         void firePropertyChange(SystemTray tray, String propertyName, Object oldValue, Object newValue);
 703     }
 704 
 705     /**
 706      * An accessor for the TrayIcon class
 707      */
 708     public interface TrayIconAccessor {
 709         void addNotify(TrayIcon trayIcon) throws AWTException;
 710         void removeNotify(TrayIcon trayIcon);
 711     }
 712 
 713     /**
 714      * An accessor for the DefaultKeyboardFocusManager class
 715      */
 716     public interface DefaultKeyboardFocusManagerAccessor {
 717         public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e);
 718     }
 719 
 720     /*
 721      * An accessor for the SequencedEventAccessor class
 722      */
 723     public interface SequencedEventAccessor {
 724         /*
 725          * Returns the nested event.
 726          */
 727         AWTEvent getNested(AWTEvent sequencedEvent);
 728 
 729         /*
 730          * Returns true if the event is an instances of SequencedEvent.
 731          */
 732         boolean isSequencedEvent(AWTEvent event);
 733     }
 734 
 735     /*
 736      * An accessor for the Toolkit class
 737      */
 738     public interface ToolkitAccessor {
 739         void setPlatformResources(ResourceBundle bundle);
 740     }
 741 
 742     /*
 743      * An accessor object for the InvocationEvent class
 744      */
 745     public interface InvocationEventAccessor {
 746         void dispose(InvocationEvent event);
 747     }
 748 
 749     /*
 750      * An accessor object for the SystemColor class
 751      */
 752     public interface SystemColorAccessor {
 753         void updateSystemColors();
 754     }
 755 
 756     /*
 757      * An accessor object for the AccessibleContext class
 758      */
 759     public interface AccessibleContextAccessor {
 760         void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
 761         AppContext getAppContext(AccessibleContext accessibleContext);
 762     }
 763 
 764     /*
 765      * Accessor instances are initialized in the static initializers of
 766      * corresponding AWT classes by using setters defined below.
 767      */
 768     private static ComponentAccessor componentAccessor;
 769     private static ContainerAccessor containerAccessor;
 770     private static WindowAccessor windowAccessor;
 771     private static AWTEventAccessor awtEventAccessor;
 772     private static InputEventAccessor inputEventAccessor;
 773     private static FrameAccessor frameAccessor;
 774     private static KeyboardFocusManagerAccessor kfmAccessor;
 775     private static MenuComponentAccessor menuComponentAccessor;
 776     private static EventQueueAccessor eventQueueAccessor;
 777     private static PopupMenuAccessor popupMenuAccessor;
 778     private static FileDialogAccessor fileDialogAccessor;
 779     private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor;
 780     private static CheckboxMenuItemAccessor checkboxMenuItemAccessor;
 781     private static CursorAccessor cursorAccessor;
 782     private static MenuBarAccessor menuBarAccessor;
 783     private static MenuItemAccessor menuItemAccessor;
 784     private static MenuAccessor menuAccessor;
 785     private static KeyEventAccessor keyEventAccessor;
 786     private static ClientPropertyKeyAccessor clientPropertyKeyAccessor;
 787     private static SystemTrayAccessor systemTrayAccessor;
 788     private static TrayIconAccessor trayIconAccessor;
 789     private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor;
 790     private static SequencedEventAccessor sequencedEventAccessor;
 791     private static ToolkitAccessor toolkitAccessor;
 792     private static InvocationEventAccessor invocationEventAccessor;
 793     private static SystemColorAccessor systemColorAccessor;
 794     private static AccessibleContextAccessor accessibleContextAccessor;
 795 
 796     /*
 797      * Set an accessor object for the java.awt.Component class.
 798      */
 799     public static void setComponentAccessor(ComponentAccessor ca) {
 800         componentAccessor = ca;
 801     }
 802 
 803     /*
 804      * Retrieve the accessor object for the java.awt.Component class.
 805      */
 806     public static ComponentAccessor getComponentAccessor() {
 807         if (componentAccessor == null) {
 808             unsafe.ensureClassInitialized(Component.class);
 809         }
 810 
 811         return componentAccessor;
 812     }
 813 
 814     /*
 815      * Set an accessor object for the java.awt.Container class.
 816      */
 817     public static void setContainerAccessor(ContainerAccessor ca) {
 818         containerAccessor = ca;
 819     }
 820 
 821     /*
 822      * Retrieve the accessor object for the java.awt.Container class.
 823      */
 824     public static ContainerAccessor getContainerAccessor() {
 825         if (containerAccessor == null) {
 826             unsafe.ensureClassInitialized(Container.class);
 827         }
 828 
 829         return containerAccessor;
 830     }
 831 
 832     /*
 833      * Set an accessor object for the java.awt.Window class.
 834      */
 835     public static void setWindowAccessor(WindowAccessor wa) {
 836         windowAccessor = wa;
 837     }
 838 
 839     /*
 840      * Retrieve the accessor object for the java.awt.Window class.
 841      */
 842     public static WindowAccessor getWindowAccessor() {
 843         if (windowAccessor == null) {
 844             unsafe.ensureClassInitialized(Window.class);
 845         }
 846         return windowAccessor;
 847     }
 848 
 849     /*
 850      * Set an accessor object for the java.awt.AWTEvent class.
 851      */
 852     public static void setAWTEventAccessor(AWTEventAccessor aea) {
 853         awtEventAccessor = aea;
 854     }
 855 
 856     /*
 857      * Retrieve the accessor object for the java.awt.AWTEvent class.
 858      */
 859     public static AWTEventAccessor getAWTEventAccessor() {
 860         if (awtEventAccessor == null) {
 861             unsafe.ensureClassInitialized(AWTEvent.class);
 862         }
 863         return awtEventAccessor;
 864     }
 865 
 866     /*
 867      * Set an accessor object for the java.awt.event.InputEvent class.
 868      */
 869     public static void setInputEventAccessor(InputEventAccessor iea) {
 870         inputEventAccessor = iea;
 871     }
 872 
 873     /*
 874      * Retrieve the accessor object for the java.awt.event.InputEvent class.
 875      */
 876     public static InputEventAccessor getInputEventAccessor() {
 877         if (inputEventAccessor == null) {
 878             unsafe.ensureClassInitialized(InputEvent.class);
 879         }
 880         return inputEventAccessor;
 881     }
 882 
 883     /*
 884      * Set an accessor object for the java.awt.Frame class.
 885      */
 886     public static void setFrameAccessor(FrameAccessor fa) {
 887         frameAccessor = fa;
 888     }
 889 
 890     /*
 891      * Retrieve the accessor object for the java.awt.Frame class.
 892      */
 893     public static FrameAccessor getFrameAccessor() {
 894         if (frameAccessor == null) {
 895             unsafe.ensureClassInitialized(Frame.class);
 896         }
 897         return frameAccessor;
 898     }
 899 
 900     /*
 901      * Set an accessor object for the java.awt.KeyboardFocusManager class.
 902      */
 903     public static void setKeyboardFocusManagerAccessor(KeyboardFocusManagerAccessor kfma) {
 904         kfmAccessor = kfma;
 905     }
 906 
 907     /*
 908      * Retrieve the accessor object for the java.awt.KeyboardFocusManager class.
 909      */
 910     public static KeyboardFocusManagerAccessor getKeyboardFocusManagerAccessor() {
 911         if (kfmAccessor == null) {
 912             unsafe.ensureClassInitialized(KeyboardFocusManager.class);
 913         }
 914         return kfmAccessor;
 915     }
 916 
 917     /*
 918      * Set an accessor object for the java.awt.MenuComponent class.
 919      */
 920     public static void setMenuComponentAccessor(MenuComponentAccessor mca) {
 921         menuComponentAccessor = mca;
 922     }
 923 
 924     /*
 925      * Retrieve the accessor object for the java.awt.MenuComponent class.
 926      */
 927     public static MenuComponentAccessor getMenuComponentAccessor() {
 928         if (menuComponentAccessor == null) {
 929             unsafe.ensureClassInitialized(MenuComponent.class);
 930         }
 931         return menuComponentAccessor;
 932     }
 933 
 934     /*
 935      * Set an accessor object for the java.awt.EventQueue class.
 936      */
 937     public static void setEventQueueAccessor(EventQueueAccessor eqa) {
 938         eventQueueAccessor = eqa;
 939     }
 940 
 941     /*
 942      * Retrieve the accessor object for the java.awt.EventQueue class.
 943      */
 944     public static EventQueueAccessor getEventQueueAccessor() {
 945         if (eventQueueAccessor == null) {
 946             unsafe.ensureClassInitialized(EventQueue.class);
 947         }
 948         return eventQueueAccessor;
 949     }
 950 
 951     /*
 952      * Set an accessor object for the java.awt.PopupMenu class.
 953      */
 954     public static void setPopupMenuAccessor(PopupMenuAccessor pma) {
 955         popupMenuAccessor = pma;
 956     }
 957 
 958     /*
 959      * Retrieve the accessor object for the java.awt.PopupMenu class.
 960      */
 961     public static PopupMenuAccessor getPopupMenuAccessor() {
 962         if (popupMenuAccessor == null) {
 963             unsafe.ensureClassInitialized(PopupMenu.class);
 964         }
 965         return popupMenuAccessor;
 966     }
 967 
 968     /*
 969      * Set an accessor object for the java.awt.FileDialog class.
 970      */
 971     public static void setFileDialogAccessor(FileDialogAccessor fda) {
 972         fileDialogAccessor = fda;
 973     }
 974 
 975     /*
 976      * Retrieve the accessor object for the java.awt.FileDialog class.
 977      */
 978     public static FileDialogAccessor getFileDialogAccessor() {
 979         if (fileDialogAccessor == null) {
 980             unsafe.ensureClassInitialized(FileDialog.class);
 981         }
 982         return fileDialogAccessor;
 983     }
 984 
 985     /*
 986      * Set an accessor object for the java.awt.ScrollPaneAdjustable class.
 987      */
 988     public static void setScrollPaneAdjustableAccessor(ScrollPaneAdjustableAccessor adj) {
 989         scrollPaneAdjustableAccessor = adj;
 990     }
 991 
 992     /*
 993      * Retrieve the accessor object for the java.awt.ScrollPaneAdjustable
 994      * class.
 995      */
 996     public static ScrollPaneAdjustableAccessor getScrollPaneAdjustableAccessor() {
 997         if (scrollPaneAdjustableAccessor == null) {
 998             unsafe.ensureClassInitialized(ScrollPaneAdjustable.class);
 999         }
1000         return scrollPaneAdjustableAccessor;
1001     }
1002 
1003     /**
1004      * Set an accessor object for the java.awt.CheckboxMenuItem class.
1005      */
1006     public static void setCheckboxMenuItemAccessor(CheckboxMenuItemAccessor cmia) {
1007         checkboxMenuItemAccessor = cmia;
1008     }
1009 
1010     /**
1011      * Retrieve the accessor object for the java.awt.CheckboxMenuItem class.
1012      */
1013     public static CheckboxMenuItemAccessor getCheckboxMenuItemAccessor() {
1014         if (checkboxMenuItemAccessor == null) {
1015             unsafe.ensureClassInitialized(CheckboxMenuItemAccessor.class);
1016         }
1017         return checkboxMenuItemAccessor;
1018     }
1019 
1020     /**
1021      * Set an accessor object for the java.awt.Cursor class.
1022      */
1023     public static void setCursorAccessor(CursorAccessor ca) {
1024         cursorAccessor = ca;
1025     }
1026 
1027     /**
1028      * Retrieve the accessor object for the java.awt.Cursor class.
1029      */
1030     public static CursorAccessor getCursorAccessor() {
1031         if (cursorAccessor == null) {
1032             unsafe.ensureClassInitialized(CursorAccessor.class);
1033         }
1034         return cursorAccessor;
1035     }
1036 
1037     /**
1038      * Set an accessor object for the java.awt.MenuBar class.
1039      */
1040     public static void setMenuBarAccessor(MenuBarAccessor mba) {
1041         menuBarAccessor = mba;
1042     }
1043 
1044     /**
1045      * Retrieve the accessor object for the java.awt.MenuBar class.
1046      */
1047     public static MenuBarAccessor getMenuBarAccessor() {
1048         if (menuBarAccessor == null) {
1049             unsafe.ensureClassInitialized(MenuBarAccessor.class);
1050         }
1051         return menuBarAccessor;
1052     }
1053 
1054     /**
1055      * Set an accessor object for the java.awt.MenuItem class.
1056      */
1057     public static void setMenuItemAccessor(MenuItemAccessor mia) {
1058         menuItemAccessor = mia;
1059     }
1060 
1061     /**
1062      * Retrieve the accessor object for the java.awt.MenuItem class.
1063      */
1064     public static MenuItemAccessor getMenuItemAccessor() {
1065         if (menuItemAccessor == null) {
1066             unsafe.ensureClassInitialized(MenuItemAccessor.class);
1067         }
1068         return menuItemAccessor;
1069     }
1070 
1071     /**
1072      * Set an accessor object for the java.awt.Menu class.
1073      */
1074     public static void setMenuAccessor(MenuAccessor ma) {
1075         menuAccessor = ma;
1076     }
1077 
1078     /**
1079      * Retrieve the accessor object for the java.awt.Menu class.
1080      */
1081     public static MenuAccessor getMenuAccessor() {
1082         if (menuAccessor == null) {
1083             unsafe.ensureClassInitialized(MenuAccessor.class);
1084         }
1085         return menuAccessor;
1086     }
1087 
1088     /**
1089      * Set an accessor object for the java.awt.event.KeyEvent class.
1090      */
1091     public static void setKeyEventAccessor(KeyEventAccessor kea) {
1092         keyEventAccessor = kea;
1093     }
1094 
1095     /**
1096      * Retrieve the accessor object for the java.awt.event.KeyEvent class.
1097      */
1098     public static KeyEventAccessor getKeyEventAccessor() {
1099         if (keyEventAccessor == null) {
1100             unsafe.ensureClassInitialized(KeyEventAccessor.class);
1101         }
1102         return keyEventAccessor;
1103     }
1104 
1105     /**
1106      * Set an accessor object for the javax.swing.ClientPropertyKey class.
1107      */
1108     public static void setClientPropertyKeyAccessor(ClientPropertyKeyAccessor cpka) {
1109         clientPropertyKeyAccessor = cpka;
1110     }
1111 
1112     /**
1113      * Retrieve the accessor object for the javax.swing.ClientPropertyKey class.
1114      */
1115     public static ClientPropertyKeyAccessor getClientPropertyKeyAccessor() {
1116         if (clientPropertyKeyAccessor == null) {
1117             unsafe.ensureClassInitialized(ClientPropertyKeyAccessor.class);
1118         }
1119         return clientPropertyKeyAccessor;
1120     }
1121 
1122     /**
1123      * Set an accessor object for the java.awt.SystemTray class.
1124      */
1125     public static void setSystemTrayAccessor(SystemTrayAccessor sta) {
1126         systemTrayAccessor = sta;
1127     }
1128 
1129     /**
1130      * Retrieve the accessor object for the java.awt.SystemTray class.
1131      */
1132     public static SystemTrayAccessor getSystemTrayAccessor() {
1133         if (systemTrayAccessor == null) {
1134             unsafe.ensureClassInitialized(SystemTrayAccessor.class);
1135         }
1136         return systemTrayAccessor;
1137     }
1138 
1139     /**
1140      * Set an accessor object for the java.awt.TrayIcon class.
1141      */
1142     public static void setTrayIconAccessor(TrayIconAccessor tia) {
1143         trayIconAccessor = tia;
1144     }
1145 
1146     /**
1147      * Retrieve the accessor object for the java.awt.TrayIcon class.
1148      */
1149     public static TrayIconAccessor getTrayIconAccessor() {
1150         if (trayIconAccessor == null) {
1151             unsafe.ensureClassInitialized(TrayIconAccessor.class);
1152         }
1153         return trayIconAccessor;
1154     }
1155 
1156     /**
1157      * Set an accessor object for the java.awt.DefaultKeyboardFocusManager class.
1158      */
1159     public static void setDefaultKeyboardFocusManagerAccessor(DefaultKeyboardFocusManagerAccessor dkfma) {
1160         defaultKeyboardFocusManagerAccessor = dkfma;
1161     }
1162 
1163     /**
1164      * Retrieve the accessor object for the java.awt.DefaultKeyboardFocusManager class.
1165      */
1166     public static DefaultKeyboardFocusManagerAccessor getDefaultKeyboardFocusManagerAccessor() {
1167         if (defaultKeyboardFocusManagerAccessor == null) {
1168             unsafe.ensureClassInitialized(DefaultKeyboardFocusManagerAccessor.class);
1169         }
1170         return defaultKeyboardFocusManagerAccessor;
1171     }
1172     /*
1173      * Set an accessor object for the java.awt.SequencedEvent class.
1174      */
1175     public static void setSequencedEventAccessor(SequencedEventAccessor sea) {
1176         sequencedEventAccessor = sea;
1177     }
1178 
1179     /*
1180      * Get the accessor object for the java.awt.SequencedEvent class.
1181      */
1182     public static SequencedEventAccessor getSequencedEventAccessor() {
1183         // The class is not public. So we can't ensure it's initialized.
1184         // Null returned value means it's not initialized
1185         // (so not a single instance of the event has been created).
1186         return sequencedEventAccessor;
1187     }
1188 
1189     /*
1190      * Set an accessor object for the java.awt.Toolkit class.
1191      */
1192     public static void setToolkitAccessor(ToolkitAccessor ta) {
1193         toolkitAccessor = ta;
1194     }
1195 
1196     /*
1197      * Get the accessor object for the java.awt.Toolkit class.
1198      */
1199     public static ToolkitAccessor getToolkitAccessor() {
1200         if (toolkitAccessor == null) {
1201             unsafe.ensureClassInitialized(Toolkit.class);
1202         }
1203 
1204         return toolkitAccessor;
1205     }
1206 
1207     /*
1208      * Get the accessor object for the java.awt.event.InvocationEvent class.
1209      */
1210     public static void setInvocationEventAccessor(InvocationEventAccessor invocationEventAccessor) {
1211         AWTAccessor.invocationEventAccessor = invocationEventAccessor;
1212     }
1213 
1214     /*
1215      * Set the accessor object for the java.awt.event.InvocationEvent class.
1216      */
1217     public static InvocationEventAccessor getInvocationEventAccessor() {
1218         return invocationEventAccessor;
1219     }
1220 
1221     /*
1222      * Get the accessor object for the java.awt.SystemColor class.
1223      */
1224     public static SystemColorAccessor getSystemColorAccessor() {
1225         if (systemColorAccessor == null) {
1226             unsafe.ensureClassInitialized(SystemColor.class);
1227         }
1228 
1229         return systemColorAccessor;
1230     }
1231 
1232      /*
1233      * Set the accessor object for the java.awt.SystemColor class.
1234      */
1235      public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
1236          AWTAccessor.systemColorAccessor = systemColorAccessor;
1237      }
1238 
1239     /*
1240      * Get the accessor object for the javax.accessibility.AccessibleContext class.
1241      */
1242     public static AccessibleContextAccessor getAccessibleContextAccessor() {
1243         if (accessibleContextAccessor == null) {
1244             unsafe.ensureClassInitialized(AccessibleContext.class);
1245         }
1246         return accessibleContextAccessor;
1247     }
1248 
1249    /*
1250     * Set the accessor object for the javax.accessibility.AccessibleContext class.
1251     */
1252     public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
1253         AWTAccessor.accessibleContextAccessor = accessor;
1254     }
1255 }