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