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