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