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 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 
  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          * Sets the delegate for the EventQueue used by FX/AWT single threaded mode
 495          */
 496         public void setFwDispatcher(EventQueue eventQueue, FwDispatcher dispatcher);
 497     }
 498 
 499     /*
 500      * An accessor for the PopupMenu class
 501      */
 502     public interface PopupMenuAccessor {
 503         /*
 504          * Returns whether the popup menu is attached to a tray
 505          */
 506         boolean isTrayIconPopup(PopupMenu popupMenu);
 507     }
 508 
 509     /*
 510      * An accessor for the FileDialog class
 511      */
 512     public interface FileDialogAccessor {
 513         /*
 514          * Sets the files the user selects
 515          */
 516         void setFiles(FileDialog fileDialog, File files[]);
 517 
 518         /*
 519          * Sets the file the user selects
 520          */
 521         void setFile(FileDialog fileDialog, String file);
 522 
 523         /*
 524          * Sets the directory the user selects
 525          */
 526         void setDirectory(FileDialog fileDialog, String directory);
 527 
 528         /*
 529          * Returns whether the file dialog allows the multiple file selection.
 530          */
 531         boolean isMultipleMode(FileDialog fileDialog);
 532     }
 533 
 534     /*
 535      * An accessor for the ScrollPaneAdjustable class.
 536      */
 537     public interface ScrollPaneAdjustableAccessor {
 538         /*
 539          * Sets the value of this scrollbar to the specified value.
 540          */
 541         void setTypedValue(final ScrollPaneAdjustable adj, final int v,
 542                            final int type);
 543     }
 544 
 545     /**
 546      * An accessor for the CheckboxMenuItem class
 547      */
 548     public interface CheckboxMenuItemAccessor {
 549         /**
 550          * Returns whether menu item is checked
 551          */
 552         boolean getState(CheckboxMenuItem cmi);
 553     }
 554 
 555     /**
 556      * An accessor for the Cursor class
 557      */
 558     public interface CursorAccessor {
 559         /**
 560          * Returns pData of the Cursor class
 561          */
 562         long getPData(Cursor cursor);
 563 
 564         /**
 565          * Sets pData to the Cursor class
 566          */
 567         void setPData(Cursor cursor, long pData);
 568 
 569         /**
 570          * Return type of the Cursor class
 571          */
 572         int getType(Cursor cursor);
 573     }
 574 
 575     /**
 576      * An accessor for the MenuBar class
 577      */
 578     public interface MenuBarAccessor {
 579         /**
 580          * Returns help menu
 581          */
 582         Menu getHelpMenu(MenuBar menuBar);
 583 
 584         /**
 585          * Returns menus
 586          */
 587         Vector getMenus(MenuBar menuBar);
 588     }
 589 
 590     /**
 591      * An accessor for the MenuItem class
 592      */
 593     public interface MenuItemAccessor {
 594         /**
 595          * Returns whether menu item is enabled
 596          */
 597         boolean isEnabled(MenuItem item);
 598 
 599         /**
 600          * Gets the command name of the action event that is fired
 601          * by this menu item.
 602          */
 603         String getActionCommandImpl(MenuItem item);
 604 
 605         /**
 606          * Returns true if the item and all its ancestors are
 607          * enabled, false otherwise
 608          */
 609         boolean isItemEnabled(MenuItem item);
 610 
 611         /**
 612          * Returns label
 613          */
 614         String getLabel(MenuItem item);
 615 
 616         /**
 617          * Returns shortcut
 618          */
 619         MenuShortcut getShortcut(MenuItem item);
 620     }
 621 
 622     /**
 623      * An accessor for the Menu class
 624      */
 625     public interface MenuAccessor {
 626         /**
 627          * Returns vector of the items that are part of the Menu
 628          */
 629         Vector getItems(Menu menu);
 630     }
 631 
 632     /**
 633      * An accessor for the KeyEvent class
 634      */
 635     public interface KeyEventAccessor {
 636         /**
 637          * Sets rawCode field for KeyEvent
 638          */
 639         void setRawCode(KeyEvent ev, long rawCode);
 640 
 641         /**
 642          * Sets primaryLevelUnicode field for KeyEvent
 643          */
 644         void setPrimaryLevelUnicode(KeyEvent ev, long primaryLevelUnicode);
 645 
 646         /**
 647          * Sets extendedKeyCode field for KeyEvent
 648          */
 649         void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode);
 650 
 651         /**
 652          * Gets original source for KeyEvent
 653          */
 654         Component getOriginalSource(KeyEvent ev);
 655     }
 656 
 657     /**
 658      * An accessor for the ClientPropertyKey class
 659      */
 660     public interface ClientPropertyKeyAccessor {
 661         /**
 662          * Retrieves JComponent_TRANSFER_HANDLER enum object
 663          */
 664         Object getJComponent_TRANSFER_HANDLER();
 665     }
 666 
 667     /**
 668      * An accessor for the SystemTray class
 669      */
 670     public interface SystemTrayAccessor {
 671         /**
 672          * Support for reporting bound property changes for Object properties.
 673          */
 674         void firePropertyChange(SystemTray tray, String propertyName, Object oldValue, Object newValue);
 675     }
 676 
 677     /**
 678      * An accessor for the TrayIcon class
 679      */
 680     public interface TrayIconAccessor {
 681         void addNotify(TrayIcon trayIcon) throws AWTException;
 682         void removeNotify(TrayIcon trayIcon);
 683     }
 684 
 685     /**
 686      * An accessor for the DefaultKeyboardFocusManager class
 687      */
 688     public interface DefaultKeyboardFocusManagerAccessor {
 689         public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e);
 690     }
 691 
 692     /*
 693      * An accessor for the SequencedEventAccessor class
 694      */
 695     public interface SequencedEventAccessor {
 696         /*
 697          * Returns the nested event.
 698          */
 699         AWTEvent getNested(AWTEvent sequencedEvent);
 700 
 701         /*
 702          * Returns true if the event is an instances of SequencedEvent.
 703          */
 704         boolean isSequencedEvent(AWTEvent event);
 705     }
 706 
 707     /*
 708      * Accessor instances are initialized in the static initializers of
 709      * corresponding AWT classes by using setters defined below.
 710      */
 711     private static ComponentAccessor componentAccessor;
 712     private static ContainerAccessor containerAccessor;
 713     private static WindowAccessor windowAccessor;
 714     private static AWTEventAccessor awtEventAccessor;
 715     private static InputEventAccessor inputEventAccessor;
 716     private static FrameAccessor frameAccessor;
 717     private static KeyboardFocusManagerAccessor kfmAccessor;
 718     private static MenuComponentAccessor menuComponentAccessor;
 719     private static EventQueueAccessor eventQueueAccessor;
 720     private static PopupMenuAccessor popupMenuAccessor;
 721     private static FileDialogAccessor fileDialogAccessor;
 722     private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor;
 723     private static CheckboxMenuItemAccessor checkboxMenuItemAccessor;
 724     private static CursorAccessor cursorAccessor;
 725     private static MenuBarAccessor menuBarAccessor;
 726     private static MenuItemAccessor menuItemAccessor;
 727     private static MenuAccessor menuAccessor;
 728     private static KeyEventAccessor keyEventAccessor;
 729     private static ClientPropertyKeyAccessor clientPropertyKeyAccessor;
 730     private static SystemTrayAccessor systemTrayAccessor;
 731     private static TrayIconAccessor trayIconAccessor;
 732     private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor;
 733     private static SequencedEventAccessor sequencedEventAccessor;
 734 
 735     /*
 736      * Set an accessor object for the java.awt.Component class.
 737      */
 738     public static void setComponentAccessor(ComponentAccessor ca) {
 739         componentAccessor = ca;
 740     }
 741 
 742     /*
 743      * Retrieve the accessor object for the java.awt.Component class.
 744      */
 745     public static ComponentAccessor getComponentAccessor() {
 746         if (componentAccessor == null) {
 747             unsafe.ensureClassInitialized(Component.class);
 748         }
 749 
 750         return componentAccessor;
 751     }
 752 
 753     /*
 754      * Set an accessor object for the java.awt.Container class.
 755      */
 756     public static void setContainerAccessor(ContainerAccessor ca) {
 757         containerAccessor = ca;
 758     }
 759 
 760     /*
 761      * Retrieve the accessor object for the java.awt.Container class.
 762      */
 763     public static ContainerAccessor getContainerAccessor() {
 764         if (containerAccessor == null) {
 765             unsafe.ensureClassInitialized(Container.class);
 766         }
 767 
 768         return containerAccessor;
 769     }
 770 
 771     /*
 772      * Set an accessor object for the java.awt.Window class.
 773      */
 774     public static void setWindowAccessor(WindowAccessor wa) {
 775         windowAccessor = wa;
 776     }
 777 
 778     /*
 779      * Retrieve the accessor object for the java.awt.Window class.
 780      */
 781     public static WindowAccessor getWindowAccessor() {
 782         if (windowAccessor == null) {
 783             unsafe.ensureClassInitialized(Window.class);
 784         }
 785         return windowAccessor;
 786     }
 787 
 788     /*
 789      * Set an accessor object for the java.awt.AWTEvent class.
 790      */
 791     public static void setAWTEventAccessor(AWTEventAccessor aea) {
 792         awtEventAccessor = aea;
 793     }
 794 
 795     /*
 796      * Retrieve the accessor object for the java.awt.AWTEvent class.
 797      */
 798     public static AWTEventAccessor getAWTEventAccessor() {
 799         if (awtEventAccessor == null) {
 800             unsafe.ensureClassInitialized(AWTEvent.class);
 801         }
 802         return awtEventAccessor;
 803     }
 804 
 805     /*
 806      * Set an accessor object for the java.awt.event.InputEvent class.
 807      */
 808     public static void setInputEventAccessor(InputEventAccessor iea) {
 809         inputEventAccessor = iea;
 810     }
 811 
 812     /*
 813      * Retrieve the accessor object for the java.awt.event.InputEvent class.
 814      */
 815     public static InputEventAccessor getInputEventAccessor() {
 816         if (inputEventAccessor == null) {
 817             unsafe.ensureClassInitialized(InputEvent.class);
 818         }
 819         return inputEventAccessor;
 820     }
 821 
 822     /*
 823      * Set an accessor object for the java.awt.Frame class.
 824      */
 825     public static void setFrameAccessor(FrameAccessor fa) {
 826         frameAccessor = fa;
 827     }
 828 
 829     /*
 830      * Retrieve the accessor object for the java.awt.Frame class.
 831      */
 832     public static FrameAccessor getFrameAccessor() {
 833         if (frameAccessor == null) {
 834             unsafe.ensureClassInitialized(Frame.class);
 835         }
 836         return frameAccessor;
 837     }
 838 
 839     /*
 840      * Set an accessor object for the java.awt.KeyboardFocusManager class.
 841      */
 842     public static void setKeyboardFocusManagerAccessor(KeyboardFocusManagerAccessor kfma) {
 843         kfmAccessor = kfma;
 844     }
 845 
 846     /*
 847      * Retrieve the accessor object for the java.awt.KeyboardFocusManager class.
 848      */
 849     public static KeyboardFocusManagerAccessor getKeyboardFocusManagerAccessor() {
 850         if (kfmAccessor == null) {
 851             unsafe.ensureClassInitialized(KeyboardFocusManager.class);
 852         }
 853         return kfmAccessor;
 854     }
 855 
 856     /*
 857      * Set an accessor object for the java.awt.MenuComponent class.
 858      */
 859     public static void setMenuComponentAccessor(MenuComponentAccessor mca) {
 860         menuComponentAccessor = mca;
 861     }
 862 
 863     /*
 864      * Retrieve the accessor object for the java.awt.MenuComponent class.
 865      */
 866     public static MenuComponentAccessor getMenuComponentAccessor() {
 867         if (menuComponentAccessor == null) {
 868             unsafe.ensureClassInitialized(MenuComponent.class);
 869         }
 870         return menuComponentAccessor;
 871     }
 872 
 873     /*
 874      * Set an accessor object for the java.awt.EventQueue class.
 875      */
 876     public static void setEventQueueAccessor(EventQueueAccessor eqa) {
 877         eventQueueAccessor = eqa;
 878     }
 879 
 880     /*
 881      * Retrieve the accessor object for the java.awt.EventQueue class.
 882      */
 883     public static EventQueueAccessor getEventQueueAccessor() {
 884         if (eventQueueAccessor == null) {
 885             unsafe.ensureClassInitialized(EventQueue.class);
 886         }
 887         return eventQueueAccessor;
 888     }
 889 
 890     /*
 891      * Set an accessor object for the java.awt.PopupMenu class.
 892      */
 893     public static void setPopupMenuAccessor(PopupMenuAccessor pma) {
 894         popupMenuAccessor = pma;
 895     }
 896 
 897     /*
 898      * Retrieve the accessor object for the java.awt.PopupMenu class.
 899      */
 900     public static PopupMenuAccessor getPopupMenuAccessor() {
 901         if (popupMenuAccessor == null) {
 902             unsafe.ensureClassInitialized(PopupMenu.class);
 903         }
 904         return popupMenuAccessor;
 905     }
 906 
 907     /*
 908      * Set an accessor object for the java.awt.FileDialog class.
 909      */
 910     public static void setFileDialogAccessor(FileDialogAccessor fda) {
 911         fileDialogAccessor = fda;
 912     }
 913 
 914     /*
 915      * Retrieve the accessor object for the java.awt.FileDialog class.
 916      */
 917     public static FileDialogAccessor getFileDialogAccessor() {
 918         if (fileDialogAccessor == null) {
 919             unsafe.ensureClassInitialized(FileDialog.class);
 920         }
 921         return fileDialogAccessor;
 922     }
 923 
 924     /*
 925      * Set an accessor object for the java.awt.ScrollPaneAdjustable class.
 926      */
 927     public static void setScrollPaneAdjustableAccessor(ScrollPaneAdjustableAccessor adj) {
 928         scrollPaneAdjustableAccessor = adj;
 929     }
 930 
 931     /*
 932      * Retrieve the accessor object for the java.awt.ScrollPaneAdjustable
 933      * class.
 934      */
 935     public static ScrollPaneAdjustableAccessor getScrollPaneAdjustableAccessor() {
 936         if (scrollPaneAdjustableAccessor == null) {
 937             unsafe.ensureClassInitialized(ScrollPaneAdjustable.class);
 938         }
 939         return scrollPaneAdjustableAccessor;
 940     }
 941 
 942     /**
 943      * Set an accessor object for the java.awt.CheckboxMenuItem class.
 944      */
 945     public static void setCheckboxMenuItemAccessor(CheckboxMenuItemAccessor cmia) {
 946         checkboxMenuItemAccessor = cmia;
 947     }
 948 
 949     /**
 950      * Retrieve the accessor object for the java.awt.CheckboxMenuItem class.
 951      */
 952     public static CheckboxMenuItemAccessor getCheckboxMenuItemAccessor() {
 953         if (checkboxMenuItemAccessor == null) {
 954             unsafe.ensureClassInitialized(CheckboxMenuItemAccessor.class);
 955         }
 956         return checkboxMenuItemAccessor;
 957     }
 958 
 959     /**
 960      * Set an accessor object for the java.awt.Cursor class.
 961      */
 962     public static void setCursorAccessor(CursorAccessor ca) {
 963         cursorAccessor = ca;
 964     }
 965 
 966     /**
 967      * Retrieve the accessor object for the java.awt.Cursor class.
 968      */
 969     public static CursorAccessor getCursorAccessor() {
 970         if (cursorAccessor == null) {
 971             unsafe.ensureClassInitialized(CursorAccessor.class);
 972         }
 973         return cursorAccessor;
 974     }
 975 
 976     /**
 977      * Set an accessor object for the java.awt.MenuBar class.
 978      */
 979     public static void setMenuBarAccessor(MenuBarAccessor mba) {
 980         menuBarAccessor = mba;
 981     }
 982 
 983     /**
 984      * Retrieve the accessor object for the java.awt.MenuBar class.
 985      */
 986     public static MenuBarAccessor getMenuBarAccessor() {
 987         if (menuBarAccessor == null) {
 988             unsafe.ensureClassInitialized(MenuBarAccessor.class);
 989         }
 990         return menuBarAccessor;
 991     }
 992 
 993     /**
 994      * Set an accessor object for the java.awt.MenuItem class.
 995      */
 996     public static void setMenuItemAccessor(MenuItemAccessor mia) {
 997         menuItemAccessor = mia;
 998     }
 999 
1000     /**
1001      * Retrieve the accessor object for the java.awt.MenuItem class.
1002      */
1003     public static MenuItemAccessor getMenuItemAccessor() {
1004         if (menuItemAccessor == null) {
1005             unsafe.ensureClassInitialized(MenuItemAccessor.class);
1006         }
1007         return menuItemAccessor;
1008     }
1009 
1010     /**
1011      * Set an accessor object for the java.awt.Menu class.
1012      */
1013     public static void setMenuAccessor(MenuAccessor ma) {
1014         menuAccessor = ma;
1015     }
1016 
1017     /**
1018      * Retrieve the accessor object for the java.awt.Menu class.
1019      */
1020     public static MenuAccessor getMenuAccessor() {
1021         if (menuAccessor == null) {
1022             unsafe.ensureClassInitialized(MenuAccessor.class);
1023         }
1024         return menuAccessor;
1025     }
1026 
1027     /**
1028      * Set an accessor object for the java.awt.event.KeyEvent class.
1029      */
1030     public static void setKeyEventAccessor(KeyEventAccessor kea) {
1031         keyEventAccessor = kea;
1032     }
1033 
1034     /**
1035      * Retrieve the accessor object for the java.awt.event.KeyEvent class.
1036      */
1037     public static KeyEventAccessor getKeyEventAccessor() {
1038         if (keyEventAccessor == null) {
1039             unsafe.ensureClassInitialized(KeyEventAccessor.class);
1040         }
1041         return keyEventAccessor;
1042     }
1043 
1044     /**
1045      * Set an accessor object for the javax.swing.ClientPropertyKey class.
1046      */
1047     public static void setClientPropertyKeyAccessor(ClientPropertyKeyAccessor cpka) {
1048         clientPropertyKeyAccessor = cpka;
1049     }
1050 
1051     /**
1052      * Retrieve the accessor object for the javax.swing.ClientPropertyKey class.
1053      */
1054     public static ClientPropertyKeyAccessor getClientPropertyKeyAccessor() {
1055         if (clientPropertyKeyAccessor == null) {
1056             unsafe.ensureClassInitialized(ClientPropertyKeyAccessor.class);
1057         }
1058         return clientPropertyKeyAccessor;
1059     }
1060 
1061     /**
1062      * Set an accessor object for the java.awt.SystemTray class.
1063      */
1064     public static void setSystemTrayAccessor(SystemTrayAccessor sta) {
1065         systemTrayAccessor = sta;
1066     }
1067 
1068     /**
1069      * Retrieve the accessor object for the java.awt.SystemTray class.
1070      */
1071     public static SystemTrayAccessor getSystemTrayAccessor() {
1072         if (systemTrayAccessor == null) {
1073             unsafe.ensureClassInitialized(SystemTrayAccessor.class);
1074         }
1075         return systemTrayAccessor;
1076     }
1077 
1078     /**
1079      * Set an accessor object for the java.awt.TrayIcon class.
1080      */
1081     public static void setTrayIconAccessor(TrayIconAccessor tia) {
1082         trayIconAccessor = tia;
1083     }
1084 
1085     /**
1086      * Retrieve the accessor object for the java.awt.TrayIcon class.
1087      */
1088     public static TrayIconAccessor getTrayIconAccessor() {
1089         if (trayIconAccessor == null) {
1090             unsafe.ensureClassInitialized(TrayIconAccessor.class);
1091         }
1092         return trayIconAccessor;
1093     }
1094 
1095     /**
1096      * Set an accessor object for the java.awt.DefaultKeyboardFocusManager class.
1097      */
1098     public static void setDefaultKeyboardFocusManagerAccessor(DefaultKeyboardFocusManagerAccessor dkfma) {
1099         defaultKeyboardFocusManagerAccessor = dkfma;
1100     }
1101 
1102     /**
1103      * Retrieve the accessor object for the java.awt.DefaultKeyboardFocusManager class.
1104      */
1105     public static DefaultKeyboardFocusManagerAccessor getDefaultKeyboardFocusManagerAccessor() {
1106         if (defaultKeyboardFocusManagerAccessor == null) {
1107             unsafe.ensureClassInitialized(DefaultKeyboardFocusManagerAccessor.class);
1108         }
1109         return defaultKeyboardFocusManagerAccessor;
1110     }
1111     /*
1112      * Set an accessor object for the java.awt.SequencedEvent class.
1113      */
1114     public static void setSequencedEventAccessor(SequencedEventAccessor sea) {
1115         sequencedEventAccessor = sea;
1116     }
1117 
1118     /*
1119      * Get the accessor object for the java.awt.SequencedEvent class.
1120      */
1121     public static SequencedEventAccessor getSequencedEventAccessor() {
1122         // The class is not public. So we can't ensure it's initialized.
1123         // Null returned value means it's not initialized
1124         // (so not a single instance of the event has been created).
1125         return sequencedEventAccessor;
1126     }
1127 }