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