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