1 /* 2 * Copyright (c) 2008, 2017, 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 jdk.internal.misc.Unsafe; 29 30 import javax.accessibility.AccessibleContext; 31 import java.awt.*; 32 import java.awt.event.FocusEvent.Cause; 33 import java.awt.dnd.DragSourceContext; 34 import java.awt.dnd.DropTargetContext; 35 import java.awt.dnd.peer.DragSourceContextPeer; 36 import java.awt.dnd.peer.DropTargetContextPeer; 37 import java.awt.event.AWTEventListener; 38 import java.awt.event.InputEvent; 39 import java.awt.event.InvocationEvent; 40 import java.awt.event.KeyEvent; 41 import java.awt.event.MouseEvent; 42 import java.awt.geom.Point2D; 43 import java.awt.image.BufferStrategy; 44 import java.awt.peer.ComponentPeer; 45 46 import java.awt.peer.MenuComponentPeer; 47 import java.lang.reflect.InvocationTargetException; 48 import java.security.AccessControlContext; 49 50 import java.io.File; 51 import java.util.ResourceBundle; 52 import java.util.Vector; 53 import javax.accessibility.AccessibleBundle; 54 55 /** 56 * The AWTAccessor utility class. 57 * The main purpose of this class is to enable accessing 58 * private and package-private fields of classes from 59 * different classes/packages. See sun.misc.SharedSecretes 60 * for another example. 61 */ 62 public final class AWTAccessor { 63 64 private static final Unsafe unsafe = Unsafe.getUnsafe(); 65 66 /* 67 * We don't need any objects of this class. 68 * It's rather a collection of static methods 69 * and interfaces. 70 */ 71 private AWTAccessor() { 72 } 73 74 /* 75 * An interface of accessor for the java.awt.Component class. 76 */ 77 public interface ComponentAccessor { 78 /* 79 * Sets whether the native background erase for a component 80 * has been disabled via SunToolkit.disableBackgroundErase(). 81 */ 82 void setBackgroundEraseDisabled(Component comp, boolean disabled); 83 /* 84 * Indicates whether the native background erase for a 85 * component has been disabled via 86 * SunToolkit.disableBackgroundErase(). 87 */ 88 boolean getBackgroundEraseDisabled(Component comp); 89 /* 90 * 91 * Gets the bounds of this component in the form of a 92 * {@code Rectangle} object. The bounds specify this 93 * component's width, height, and location relative to 94 * its parent. 95 */ 96 Rectangle getBounds(Component comp); 97 98 /** 99 * Sets GraphicsConfiguration value for the component. 100 */ 101 void setGraphicsConfiguration(Component comp, GraphicsConfiguration gc); 102 /* 103 * Requests focus to the component. 104 */ 105 void requestFocus(Component comp, Cause cause); 106 /* 107 * Determines if the component can gain focus. 108 */ 109 boolean canBeFocusOwner(Component comp); 110 111 /** 112 * Returns whether the component is visible without invoking 113 * any client code. 114 */ 115 boolean isVisible(Component comp); 116 117 /** 118 * Sets the RequestFocusController. 119 */ 120 void setRequestFocusController(RequestFocusController requestController); 121 122 /** 123 * Returns the appContext of the component. 124 */ 125 AppContext getAppContext(Component comp); 126 127 /** 128 * Sets the appContext of the component. 129 */ 130 void setAppContext(Component comp, AppContext appContext); 131 132 /** 133 * Returns the parent of the component. 134 */ 135 Container getParent(Component comp); 136 137 /** 138 * Sets the parent of the component to the specified parent. 139 */ 140 void setParent(Component comp, Container parent); 141 142 /** 143 * Resizes the component to the specified width and height. 144 */ 145 void setSize(Component comp, int width, int height); 146 147 /** 148 * Returns the location of the component. 149 */ 150 Point getLocation(Component comp); 151 152 /** 153 * Moves the component to the new location. 154 */ 155 void setLocation(Component comp, int x, int y); 156 157 /** 158 * Determines whether this component is enabled. 159 */ 160 boolean isEnabled(Component comp); 161 162 /** 163 * Determines whether this component is displayable. 164 */ 165 boolean isDisplayable(Component comp); 166 167 /** 168 * Gets the cursor set in the component. 169 */ 170 Cursor getCursor(Component comp); 171 172 /** 173 * Returns the peer of the component. 174 */ 175 <T extends ComponentPeer> T getPeer(Component comp); 176 177 /** 178 * Sets the peer of the component to the specified peer. 179 */ 180 void setPeer(Component comp, ComponentPeer peer); 181 182 /** 183 * Determines whether this component is lightweight. 184 */ 185 boolean isLightweight(Component comp); 186 187 /** 188 * Returns whether or not paint messages received from 189 * the operating system should be ignored. 190 */ 191 boolean getIgnoreRepaint(Component comp); 192 193 /** 194 * Returns the width of the component. 195 */ 196 int getWidth(Component comp); 197 198 /** 199 * Returns the height of the component. 200 */ 201 int getHeight(Component comp); 202 203 /** 204 * Returns the x coordinate of the component. 205 */ 206 int getX(Component comp); 207 208 /** 209 * Returns the y coordinate of the component. 210 */ 211 int getY(Component comp); 212 213 /** 214 * Gets the foreground color of this component. 215 */ 216 Color getForeground(Component comp); 217 218 /** 219 * Gets the background color of this component. 220 */ 221 Color getBackground(Component comp); 222 223 /** 224 * Sets the background of this component to the specified color. 225 */ 226 void setBackground(Component comp, Color background); 227 228 /** 229 * Gets the font of the component. 230 */ 231 Font getFont(Component comp); 232 233 /** 234 * Processes events occurring on this component. 235 */ 236 void processEvent(Component comp, AWTEvent e); 237 238 239 /* 240 * Returns the acc this component was constructed with. 241 */ 242 AccessControlContext getAccessControlContext(Component comp); 243 244 /** 245 * Revalidates the component synchronously. 246 */ 247 void revalidateSynchronously(Component comp); 248 249 /** 250 * Creates a new strategy for multi-buffering on this component. 251 */ 252 void createBufferStrategy(Component comp, int numBuffers, 253 BufferCapabilities caps) throws AWTException; 254 255 /** 256 * returns the buffer strategy used by this component. 257 */ 258 BufferStrategy getBufferStrategy(Component comp); 259 } 260 261 /* 262 * An interface of accessor for the java.awt.Container class. 263 */ 264 public interface ContainerAccessor { 265 /** 266 * Validates the container unconditionally. 267 */ 268 void validateUnconditionally(Container cont); 269 270 /** 271 * 272 * Access to the private version of findComponentAt method which has 273 * a controllable behavior. Setting 'ignoreEnabled' to 'false' 274 * bypasses disabled Components during the search. 275 */ 276 Component findComponentAt(Container cont, int x, int y, boolean ignoreEnabled); 277 278 /** 279 * Starts LW Modal. 280 */ 281 void startLWModal(Container cont); 282 283 /** 284 * Starts LW Modal. 285 */ 286 void stopLWModal(Container cont); 287 } 288 289 /* 290 * An interface of accessor for java.awt.Window class. 291 */ 292 public interface WindowAccessor { 293 /* 294 * Update the image of a non-opaque (translucent) window. 295 */ 296 void updateWindow(Window window); 297 298 /** Get the size of the security warning. 299 */ 300 Dimension getSecurityWarningSize(Window w); 301 302 /** 303 * Set the size of the security warning. 304 */ 305 void setSecurityWarningSize(Window w, int width, int height); 306 307 /** Set the position of the security warning. 308 */ 309 void setSecurityWarningPosition(Window w, Point2D point, 310 float alignmentX, float alignmentY); 311 312 /** Request to recalculate the new position of the security warning for 313 * the given window size/location as reported by the native system. 314 */ 315 Point2D calculateSecurityWarningPosition(Window window, 316 double x, double y, double w, double h); 317 318 /** Sets the synchronous status of focus requests on lightweight 319 * components in the specified window to the specified value. 320 */ 321 void setLWRequestStatus(Window changed, boolean status); 322 323 /** 324 * Indicates whether this window should receive focus on subsequently 325 * being shown, or being moved to the front. 326 */ 327 boolean isAutoRequestFocus(Window w); 328 329 /** 330 * Indicates whether the specified window is an utility window for TrayIcon. 331 */ 332 boolean isTrayIconWindow(Window w); 333 334 /** 335 * Marks the specified window as an utility window for TrayIcon. 336 */ 337 void setTrayIconWindow(Window w, boolean isTrayIconWindow); 338 339 /** 340 * Return an array containing all the windows this 341 * window currently owns. 342 */ 343 Window[] getOwnedWindows(Window w); 344 } 345 346 /** 347 * An accessor for the AWTEvent class. 348 */ 349 public interface AWTEventAccessor { 350 /** 351 * Marks the event as posted. 352 */ 353 void setPosted(AWTEvent ev); 354 355 /** 356 * Sets the flag on this AWTEvent indicating that it was 357 * generated by the system. 358 */ 359 void setSystemGenerated(AWTEvent ev); 360 361 /** 362 * Indicates whether this AWTEvent was generated by the system. 363 */ 364 boolean isSystemGenerated(AWTEvent ev); 365 366 /** 367 * Returns the acc this event was constructed with. 368 */ 369 AccessControlContext getAccessControlContext(AWTEvent ev); 370 371 /** 372 * Returns binary data associated with this event; 373 */ 374 byte[] getBData(AWTEvent ev); 375 376 /** 377 * Associates binary data with this event; 378 */ 379 void setBData(AWTEvent ev, byte[] bdata); 380 } 381 382 public interface InputEventAccessor { 383 /* 384 * Accessor for InputEvent.getButtonDownMasks() 385 */ 386 int[] getButtonDownMasks(); 387 388 /* 389 * Accessor for InputEvent.canAccessSystemClipboard field 390 */ 391 boolean canAccessSystemClipboard(InputEvent event); 392 void setCanAccessSystemClipboard(InputEvent event, 393 boolean canAccessSystemClipboard); 394 } 395 396 /** 397 * An accessor for the MouseEvent class. 398 */ 399 public interface MouseEventAccessor { 400 /** 401 * Indicates whether the event is a result of a touch event. 402 */ 403 boolean isCausedByTouchEvent(MouseEvent ev); 404 405 /** 406 * Sets whether the event is a result of a touch event. 407 */ 408 void setCausedByTouchEvent(MouseEvent ev, boolean causedByTouchEvent); 409 } 410 411 /* 412 * An accessor for the java.awt.Frame class. 413 */ 414 public interface FrameAccessor { 415 /* 416 * Sets the state of this frame. 417 */ 418 void setExtendedState(Frame frame, int state); 419 /* 420 * Gets the state of this frame. 421 */ 422 int getExtendedState(Frame frame); 423 /* 424 * Gets the maximized bounds of this frame. 425 */ 426 Rectangle getMaximizedBounds(Frame frame); 427 } 428 429 /** 430 * An interface of accessor for the java.awt.KeyboardFocusManager class. 431 */ 432 public interface KeyboardFocusManagerAccessor { 433 /** 434 * Indicates whether the native implementation should 435 * proceed with a pending focus request for the heavyweight. 436 */ 437 int shouldNativelyFocusHeavyweight(Component heavyweight, 438 Component descendant, 439 boolean temporary, 440 boolean focusedWindowChangeAllowed, 441 long time, 442 Cause cause); 443 /** 444 * Delivers focus for the lightweight descendant of the heavyweight 445 * synchronously. 446 */ 447 boolean processSynchronousLightweightTransfer(Component heavyweight, 448 Component descendant, 449 boolean temporary, 450 boolean focusedWindowChangeAllowed, 451 long time); 452 /** 453 * Removes the last focus request for the heavyweight from the queue. 454 */ 455 void removeLastFocusRequest(Component heavyweight); 456 457 /** 458 * Gets the most recent focus owner in the window. 459 */ 460 Component getMostRecentFocusOwner(Window window); 461 462 /** 463 * Sets the most recent focus owner in the window. 464 */ 465 void setMostRecentFocusOwner(Window window, Component component); 466 467 /** 468 * Returns current KFM of the specified AppContext. 469 */ 470 KeyboardFocusManager getCurrentKeyboardFocusManager(AppContext ctx); 471 472 /** 473 * Return the current focus cycle root 474 */ 475 Container getCurrentFocusCycleRoot(); 476 } 477 478 /** 479 * An accessor for the MenuComponent class. 480 */ 481 public interface MenuComponentAccessor { 482 /** 483 * Returns the appContext of the menu component. 484 */ 485 AppContext getAppContext(MenuComponent menuComp); 486 487 /** 488 * Sets the appContext of the menu component. 489 */ 490 void setAppContext(MenuComponent menuComp, AppContext appContext); 491 492 /** 493 * Returns the peer of the menu component. 494 */ 495 <T extends MenuComponentPeer> T getPeer(MenuComponent menuComp); 496 497 /** 498 * Returns the menu container of the menu component. 499 */ 500 MenuContainer getParent(MenuComponent menuComp); 501 502 /** 503 * Sets the menu container of the menu component. 504 */ 505 void setParent(MenuComponent menuComp, MenuContainer menuContainer); 506 507 /** 508 * Gets the font used for this menu component. 509 */ 510 Font getFont_NoClientCode(MenuComponent menuComp); 511 } 512 513 /** 514 * An accessor for the EventQueue class 515 */ 516 public interface EventQueueAccessor { 517 /** 518 * Gets the event dispatch thread. 519 */ 520 Thread getDispatchThread(EventQueue eventQueue); 521 522 /** 523 * Checks if the current thread is EDT for the given EQ. 524 */ 525 public boolean isDispatchThreadImpl(EventQueue eventQueue); 526 527 /** 528 * Removes any pending events for the specified source object. 529 */ 530 void removeSourceEvents(EventQueue eventQueue, Object source, boolean removeAllEvents); 531 532 /** 533 * Returns whether an event is pending on any of the separate Queues. 534 */ 535 boolean noEvents(EventQueue eventQueue); 536 537 /** 538 * Called from PostEventQueue.postEvent to notify that a new event 539 * appeared. 540 */ 541 void wakeup(EventQueue eventQueue, boolean isShutdown); 542 543 /** 544 * Static in EventQueue 545 */ 546 void invokeAndWait(Object source, Runnable r) 547 throws InterruptedException, InvocationTargetException; 548 549 /** 550 * Sets the delegate for the EventQueue used by FX/AWT single threaded mode 551 */ 552 void setFwDispatcher(EventQueue eventQueue, FwDispatcher dispatcher); 553 554 /** 555 * Gets most recent event time in the EventQueue 556 */ 557 long getMostRecentEventTime(EventQueue eventQueue); 558 } 559 560 /* 561 * An accessor for the PopupMenu class 562 */ 563 public interface PopupMenuAccessor { 564 /* 565 * Returns whether the popup menu is attached to a tray 566 */ 567 boolean isTrayIconPopup(PopupMenu popupMenu); 568 } 569 570 /* 571 * An accessor for the FileDialog class 572 */ 573 public interface FileDialogAccessor { 574 /* 575 * Sets the files the user selects 576 */ 577 void setFiles(FileDialog fileDialog, File files[]); 578 579 /* 580 * Sets the file the user selects 581 */ 582 void setFile(FileDialog fileDialog, String file); 583 584 /* 585 * Sets the directory the user selects 586 */ 587 void setDirectory(FileDialog fileDialog, String directory); 588 589 /* 590 * Returns whether the file dialog allows the multiple file selection. 591 */ 592 boolean isMultipleMode(FileDialog fileDialog); 593 } 594 595 /* 596 * An accessor for the ScrollPaneAdjustable class. 597 */ 598 public interface ScrollPaneAdjustableAccessor { 599 /* 600 * Sets the value of this scrollbar to the specified value. 601 */ 602 void setTypedValue(final ScrollPaneAdjustable adj, final int v, 603 final int type); 604 } 605 606 /** 607 * An accessor for the CheckboxMenuItem class 608 */ 609 public interface CheckboxMenuItemAccessor { 610 /** 611 * Returns whether menu item is checked 612 */ 613 boolean getState(CheckboxMenuItem cmi); 614 } 615 616 /** 617 * An accessor for the Cursor class 618 */ 619 public interface CursorAccessor { 620 /** 621 * Returns pData of the Cursor class 622 */ 623 long getPData(Cursor cursor); 624 625 /** 626 * Sets pData to the Cursor class 627 */ 628 void setPData(Cursor cursor, long pData); 629 630 /** 631 * Return type of the Cursor class 632 */ 633 int getType(Cursor cursor); 634 } 635 636 /** 637 * An accessor for the MenuBar class 638 */ 639 public interface MenuBarAccessor { 640 /** 641 * Returns help menu 642 */ 643 Menu getHelpMenu(MenuBar menuBar); 644 645 /** 646 * Returns menus 647 */ 648 Vector<Menu> getMenus(MenuBar menuBar); 649 } 650 651 /** 652 * An accessor for the MenuItem class 653 */ 654 public interface MenuItemAccessor { 655 /** 656 * Returns whether menu item is enabled 657 */ 658 boolean isEnabled(MenuItem item); 659 660 /** 661 * Gets the command name of the action event that is fired 662 * by this menu item. 663 */ 664 String getActionCommandImpl(MenuItem item); 665 666 /** 667 * Returns true if the item and all its ancestors are 668 * enabled, false otherwise 669 */ 670 boolean isItemEnabled(MenuItem item); 671 672 /** 673 * Returns label 674 */ 675 String getLabel(MenuItem item); 676 677 /** 678 * Returns shortcut 679 */ 680 MenuShortcut getShortcut(MenuItem item); 681 } 682 683 /** 684 * An accessor for the Menu class 685 */ 686 public interface MenuAccessor { 687 /** 688 * Returns vector of the items that are part of the Menu 689 */ 690 Vector<MenuItem> getItems(Menu menu); 691 } 692 693 /** 694 * An accessor for the KeyEvent class 695 */ 696 public interface KeyEventAccessor { 697 /** 698 * Sets rawCode field for KeyEvent 699 */ 700 void setRawCode(KeyEvent ev, long rawCode); 701 702 /** 703 * Sets primaryLevelUnicode field for KeyEvent 704 */ 705 void setPrimaryLevelUnicode(KeyEvent ev, long primaryLevelUnicode); 706 707 /** 708 * Sets extendedKeyCode field for KeyEvent 709 */ 710 void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode); 711 712 /** 713 * Gets original source for KeyEvent 714 */ 715 Component getOriginalSource(KeyEvent ev); 716 717 /** 718 * Gets isProxyActive field for KeyEvent 719 */ 720 boolean isProxyActive(KeyEvent ev); 721 } 722 723 /** 724 * An accessor for the ClientPropertyKey class 725 */ 726 public interface ClientPropertyKeyAccessor { 727 /** 728 * Retrieves JComponent_TRANSFER_HANDLER enum object 729 */ 730 Object getJComponent_TRANSFER_HANDLER(); 731 } 732 733 /** 734 * An accessor for the SystemTray class 735 */ 736 public interface SystemTrayAccessor { 737 /** 738 * Support for reporting bound property changes for Object properties. 739 */ 740 void firePropertyChange(SystemTray tray, String propertyName, Object oldValue, Object newValue); 741 } 742 743 /** 744 * An accessor for the TrayIcon class 745 */ 746 public interface TrayIconAccessor { 747 void addNotify(TrayIcon trayIcon) throws AWTException; 748 void removeNotify(TrayIcon trayIcon); 749 } 750 751 /** 752 * An accessor for the DefaultKeyboardFocusManager class 753 */ 754 public interface DefaultKeyboardFocusManagerAccessor { 755 public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e); 756 } 757 758 /* 759 * An accessor for the SequencedEventAccessor class 760 */ 761 public interface SequencedEventAccessor { 762 /* 763 * Returns the nested event. 764 */ 765 AWTEvent getNested(AWTEvent sequencedEvent); 766 767 /* 768 * Returns true if the event is an instances of SequencedEvent. 769 */ 770 boolean isSequencedEvent(AWTEvent event); 771 772 /* 773 * Creates SequencedEvent with the given nested event 774 */ 775 AWTEvent create(AWTEvent event); 776 } 777 778 /* 779 * An accessor for the Toolkit class 780 */ 781 public interface ToolkitAccessor { 782 void setPlatformResources(ResourceBundle bundle); 783 } 784 785 /* 786 * An accessor object for the InvocationEvent class 787 */ 788 public interface InvocationEventAccessor { 789 void dispose(InvocationEvent event); 790 } 791 792 /* 793 * An accessor object for the SystemColor class 794 */ 795 public interface SystemColorAccessor { 796 void updateSystemColors(); 797 } 798 799 /* 800 * An accessor object for the AccessibleContext class 801 */ 802 public interface AccessibleContextAccessor { 803 void setAppContext(AccessibleContext accessibleContext, AppContext appContext); 804 AppContext getAppContext(AccessibleContext accessibleContext); 805 Object getNativeAXResource(AccessibleContext accessibleContext); 806 void setNativeAXResource(AccessibleContext accessibleContext, Object value); 807 } 808 809 /* 810 * An accessor object for the AccessibleContext class 811 */ 812 public interface AccessibleBundleAccessor { 813 String getKey(AccessibleBundle accessibleBundle); 814 } 815 816 /* 817 * An accessor object for the DragSourceContext class 818 */ 819 public interface DragSourceContextAccessor { 820 /** 821 * Returns the peer of the DragSourceContext. 822 */ 823 DragSourceContextPeer getPeer(DragSourceContext dsc); 824 } 825 826 /* 827 * An accessor object for the DropTargetContext class 828 */ 829 public interface DropTargetContextAccessor { 830 /** 831 * Resets the DropTargetContext. 832 */ 833 void reset(DropTargetContext dtc); 834 /** 835 * Sets the {@code DropTargetContextPeer} 836 */ 837 void setDropTargetContextPeer(DropTargetContext dtc, 838 DropTargetContextPeer dtcp); 839 } 840 841 /* 842 * Accessor instances are initialized in the static initializers of 843 * corresponding AWT classes by using setters defined below. 844 */ 845 private static ComponentAccessor componentAccessor; 846 private static ContainerAccessor containerAccessor; 847 private static WindowAccessor windowAccessor; 848 private static AWTEventAccessor awtEventAccessor; 849 private static InputEventAccessor inputEventAccessor; 850 private static MouseEventAccessor mouseEventAccessor; 851 private static FrameAccessor frameAccessor; 852 private static KeyboardFocusManagerAccessor kfmAccessor; 853 private static MenuComponentAccessor menuComponentAccessor; 854 private static EventQueueAccessor eventQueueAccessor; 855 private static PopupMenuAccessor popupMenuAccessor; 856 private static FileDialogAccessor fileDialogAccessor; 857 private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor; 858 private static CheckboxMenuItemAccessor checkboxMenuItemAccessor; 859 private static CursorAccessor cursorAccessor; 860 private static MenuBarAccessor menuBarAccessor; 861 private static MenuItemAccessor menuItemAccessor; 862 private static MenuAccessor menuAccessor; 863 private static KeyEventAccessor keyEventAccessor; 864 private static ClientPropertyKeyAccessor clientPropertyKeyAccessor; 865 private static SystemTrayAccessor systemTrayAccessor; 866 private static TrayIconAccessor trayIconAccessor; 867 private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor; 868 private static SequencedEventAccessor sequencedEventAccessor; 869 private static ToolkitAccessor toolkitAccessor; 870 private static InvocationEventAccessor invocationEventAccessor; 871 private static SystemColorAccessor systemColorAccessor; 872 private static AccessibleContextAccessor accessibleContextAccessor; 873 private static AccessibleBundleAccessor accessibleBundleAccessor; 874 private static DragSourceContextAccessor dragSourceContextAccessor; 875 private static DropTargetContextAccessor dropTargetContextAccessor; 876 877 /* 878 * Set an accessor object for the java.awt.Component class. 879 */ 880 public static void setComponentAccessor(ComponentAccessor ca) { 881 componentAccessor = ca; 882 } 883 884 /* 885 * Retrieve the accessor object for the java.awt.Component class. 886 */ 887 public static ComponentAccessor getComponentAccessor() { 888 if (componentAccessor == null) { 889 unsafe.ensureClassInitialized(Component.class); 890 } 891 892 return componentAccessor; 893 } 894 895 /* 896 * Set an accessor object for the java.awt.Container class. 897 */ 898 public static void setContainerAccessor(ContainerAccessor ca) { 899 containerAccessor = ca; 900 } 901 902 /* 903 * Retrieve the accessor object for the java.awt.Container class. 904 */ 905 public static ContainerAccessor getContainerAccessor() { 906 if (containerAccessor == null) { 907 unsafe.ensureClassInitialized(Container.class); 908 } 909 910 return containerAccessor; 911 } 912 913 /* 914 * Set an accessor object for the java.awt.Window class. 915 */ 916 public static void setWindowAccessor(WindowAccessor wa) { 917 windowAccessor = wa; 918 } 919 920 /* 921 * Retrieve the accessor object for the java.awt.Window class. 922 */ 923 public static WindowAccessor getWindowAccessor() { 924 if (windowAccessor == null) { 925 unsafe.ensureClassInitialized(Window.class); 926 } 927 return windowAccessor; 928 } 929 930 /* 931 * Set an accessor object for the java.awt.AWTEvent class. 932 */ 933 public static void setAWTEventAccessor(AWTEventAccessor aea) { 934 awtEventAccessor = aea; 935 } 936 937 /* 938 * Retrieve the accessor object for the java.awt.AWTEvent class. 939 */ 940 public static AWTEventAccessor getAWTEventAccessor() { 941 if (awtEventAccessor == null) { 942 unsafe.ensureClassInitialized(AWTEvent.class); 943 } 944 return awtEventAccessor; 945 } 946 947 /* 948 * Set an accessor object for the java.awt.event.InputEvent class. 949 */ 950 public static void setInputEventAccessor(InputEventAccessor iea) { 951 inputEventAccessor = iea; 952 } 953 954 /* 955 * Retrieve the accessor object for the java.awt.event.InputEvent class. 956 */ 957 public static InputEventAccessor getInputEventAccessor() { 958 if (inputEventAccessor == null) { 959 unsafe.ensureClassInitialized(InputEvent.class); 960 } 961 return inputEventAccessor; 962 } 963 964 /* 965 * Set an accessor object for the java.awt.event.MouseEvent class. 966 */ 967 public static void setMouseEventAccessor(MouseEventAccessor mea) { 968 mouseEventAccessor = mea; 969 } 970 971 /* 972 * Retrieve the accessor object for the java.awt.event.MouseEvent class. 973 */ 974 public static MouseEventAccessor getMouseEventAccessor() { 975 if (mouseEventAccessor == null) { 976 unsafe.ensureClassInitialized(MouseEvent.class); 977 } 978 return mouseEventAccessor; 979 } 980 981 /* 982 * Set an accessor object for the java.awt.Frame class. 983 */ 984 public static void setFrameAccessor(FrameAccessor fa) { 985 frameAccessor = fa; 986 } 987 988 /* 989 * Retrieve the accessor object for the java.awt.Frame class. 990 */ 991 public static FrameAccessor getFrameAccessor() { 992 if (frameAccessor == null) { 993 unsafe.ensureClassInitialized(Frame.class); 994 } 995 return frameAccessor; 996 } 997 998 /* 999 * Set an accessor object for the java.awt.KeyboardFocusManager class. 1000 */ 1001 public static void setKeyboardFocusManagerAccessor(KeyboardFocusManagerAccessor kfma) { 1002 kfmAccessor = kfma; 1003 } 1004 1005 /* 1006 * Retrieve the accessor object for the java.awt.KeyboardFocusManager class. 1007 */ 1008 public static KeyboardFocusManagerAccessor getKeyboardFocusManagerAccessor() { 1009 if (kfmAccessor == null) { 1010 unsafe.ensureClassInitialized(KeyboardFocusManager.class); 1011 } 1012 return kfmAccessor; 1013 } 1014 1015 /* 1016 * Set an accessor object for the java.awt.MenuComponent class. 1017 */ 1018 public static void setMenuComponentAccessor(MenuComponentAccessor mca) { 1019 menuComponentAccessor = mca; 1020 } 1021 1022 /* 1023 * Retrieve the accessor object for the java.awt.MenuComponent class. 1024 */ 1025 public static MenuComponentAccessor getMenuComponentAccessor() { 1026 if (menuComponentAccessor == null) { 1027 unsafe.ensureClassInitialized(MenuComponent.class); 1028 } 1029 return menuComponentAccessor; 1030 } 1031 1032 /* 1033 * Set an accessor object for the java.awt.EventQueue class. 1034 */ 1035 public static void setEventQueueAccessor(EventQueueAccessor eqa) { 1036 eventQueueAccessor = eqa; 1037 } 1038 1039 /* 1040 * Retrieve the accessor object for the java.awt.EventQueue class. 1041 */ 1042 public static EventQueueAccessor getEventQueueAccessor() { 1043 if (eventQueueAccessor == null) { 1044 unsafe.ensureClassInitialized(EventQueue.class); 1045 } 1046 return eventQueueAccessor; 1047 } 1048 1049 /* 1050 * Set an accessor object for the java.awt.PopupMenu class. 1051 */ 1052 public static void setPopupMenuAccessor(PopupMenuAccessor pma) { 1053 popupMenuAccessor = pma; 1054 } 1055 1056 /* 1057 * Retrieve the accessor object for the java.awt.PopupMenu class. 1058 */ 1059 public static PopupMenuAccessor getPopupMenuAccessor() { 1060 if (popupMenuAccessor == null) { 1061 unsafe.ensureClassInitialized(PopupMenu.class); 1062 } 1063 return popupMenuAccessor; 1064 } 1065 1066 /* 1067 * Set an accessor object for the java.awt.FileDialog class. 1068 */ 1069 public static void setFileDialogAccessor(FileDialogAccessor fda) { 1070 fileDialogAccessor = fda; 1071 } 1072 1073 /* 1074 * Retrieve the accessor object for the java.awt.FileDialog class. 1075 */ 1076 public static FileDialogAccessor getFileDialogAccessor() { 1077 if (fileDialogAccessor == null) { 1078 unsafe.ensureClassInitialized(FileDialog.class); 1079 } 1080 return fileDialogAccessor; 1081 } 1082 1083 /* 1084 * Set an accessor object for the java.awt.ScrollPaneAdjustable class. 1085 */ 1086 public static void setScrollPaneAdjustableAccessor(ScrollPaneAdjustableAccessor adj) { 1087 scrollPaneAdjustableAccessor = adj; 1088 } 1089 1090 /* 1091 * Retrieve the accessor object for the java.awt.ScrollPaneAdjustable 1092 * class. 1093 */ 1094 public static ScrollPaneAdjustableAccessor getScrollPaneAdjustableAccessor() { 1095 if (scrollPaneAdjustableAccessor == null) { 1096 unsafe.ensureClassInitialized(ScrollPaneAdjustable.class); 1097 } 1098 return scrollPaneAdjustableAccessor; 1099 } 1100 1101 /** 1102 * Set an accessor object for the java.awt.CheckboxMenuItem class. 1103 */ 1104 public static void setCheckboxMenuItemAccessor(CheckboxMenuItemAccessor cmia) { 1105 checkboxMenuItemAccessor = cmia; 1106 } 1107 1108 /** 1109 * Retrieve the accessor object for the java.awt.CheckboxMenuItem class. 1110 */ 1111 public static CheckboxMenuItemAccessor getCheckboxMenuItemAccessor() { 1112 if (checkboxMenuItemAccessor == null) { 1113 unsafe.ensureClassInitialized(CheckboxMenuItemAccessor.class); 1114 } 1115 return checkboxMenuItemAccessor; 1116 } 1117 1118 /** 1119 * Set an accessor object for the java.awt.Cursor class. 1120 */ 1121 public static void setCursorAccessor(CursorAccessor ca) { 1122 cursorAccessor = ca; 1123 } 1124 1125 /** 1126 * Retrieve the accessor object for the java.awt.Cursor class. 1127 */ 1128 public static CursorAccessor getCursorAccessor() { 1129 if (cursorAccessor == null) { 1130 unsafe.ensureClassInitialized(CursorAccessor.class); 1131 } 1132 return cursorAccessor; 1133 } 1134 1135 /** 1136 * Set an accessor object for the java.awt.MenuBar class. 1137 */ 1138 public static void setMenuBarAccessor(MenuBarAccessor mba) { 1139 menuBarAccessor = mba; 1140 } 1141 1142 /** 1143 * Retrieve the accessor object for the java.awt.MenuBar class. 1144 */ 1145 public static MenuBarAccessor getMenuBarAccessor() { 1146 if (menuBarAccessor == null) { 1147 unsafe.ensureClassInitialized(MenuBarAccessor.class); 1148 } 1149 return menuBarAccessor; 1150 } 1151 1152 /** 1153 * Set an accessor object for the java.awt.MenuItem class. 1154 */ 1155 public static void setMenuItemAccessor(MenuItemAccessor mia) { 1156 menuItemAccessor = mia; 1157 } 1158 1159 /** 1160 * Retrieve the accessor object for the java.awt.MenuItem class. 1161 */ 1162 public static MenuItemAccessor getMenuItemAccessor() { 1163 if (menuItemAccessor == null) { 1164 unsafe.ensureClassInitialized(MenuItemAccessor.class); 1165 } 1166 return menuItemAccessor; 1167 } 1168 1169 /** 1170 * Set an accessor object for the java.awt.Menu class. 1171 */ 1172 public static void setMenuAccessor(MenuAccessor ma) { 1173 menuAccessor = ma; 1174 } 1175 1176 /** 1177 * Retrieve the accessor object for the java.awt.Menu class. 1178 */ 1179 public static MenuAccessor getMenuAccessor() { 1180 if (menuAccessor == null) { 1181 unsafe.ensureClassInitialized(MenuAccessor.class); 1182 } 1183 return menuAccessor; 1184 } 1185 1186 /** 1187 * Set an accessor object for the java.awt.event.KeyEvent class. 1188 */ 1189 public static void setKeyEventAccessor(KeyEventAccessor kea) { 1190 keyEventAccessor = kea; 1191 } 1192 1193 /** 1194 * Retrieve the accessor object for the java.awt.event.KeyEvent class. 1195 */ 1196 public static KeyEventAccessor getKeyEventAccessor() { 1197 if (keyEventAccessor == null) { 1198 unsafe.ensureClassInitialized(KeyEventAccessor.class); 1199 } 1200 return keyEventAccessor; 1201 } 1202 1203 /** 1204 * Set an accessor object for the javax.swing.ClientPropertyKey class. 1205 */ 1206 public static void setClientPropertyKeyAccessor(ClientPropertyKeyAccessor cpka) { 1207 clientPropertyKeyAccessor = cpka; 1208 } 1209 1210 /** 1211 * Retrieve the accessor object for the javax.swing.ClientPropertyKey class. 1212 */ 1213 public static ClientPropertyKeyAccessor getClientPropertyKeyAccessor() { 1214 if (clientPropertyKeyAccessor == null) { 1215 unsafe.ensureClassInitialized(ClientPropertyKeyAccessor.class); 1216 } 1217 return clientPropertyKeyAccessor; 1218 } 1219 1220 /** 1221 * Set an accessor object for the java.awt.SystemTray class. 1222 */ 1223 public static void setSystemTrayAccessor(SystemTrayAccessor sta) { 1224 systemTrayAccessor = sta; 1225 } 1226 1227 /** 1228 * Retrieve the accessor object for the java.awt.SystemTray class. 1229 */ 1230 public static SystemTrayAccessor getSystemTrayAccessor() { 1231 if (systemTrayAccessor == null) { 1232 unsafe.ensureClassInitialized(SystemTrayAccessor.class); 1233 } 1234 return systemTrayAccessor; 1235 } 1236 1237 /** 1238 * Set an accessor object for the java.awt.TrayIcon class. 1239 */ 1240 public static void setTrayIconAccessor(TrayIconAccessor tia) { 1241 trayIconAccessor = tia; 1242 } 1243 1244 /** 1245 * Retrieve the accessor object for the java.awt.TrayIcon class. 1246 */ 1247 public static TrayIconAccessor getTrayIconAccessor() { 1248 if (trayIconAccessor == null) { 1249 unsafe.ensureClassInitialized(TrayIconAccessor.class); 1250 } 1251 return trayIconAccessor; 1252 } 1253 1254 /** 1255 * Set an accessor object for the java.awt.DefaultKeyboardFocusManager class. 1256 */ 1257 public static void setDefaultKeyboardFocusManagerAccessor(DefaultKeyboardFocusManagerAccessor dkfma) { 1258 defaultKeyboardFocusManagerAccessor = dkfma; 1259 } 1260 1261 /** 1262 * Retrieve the accessor object for the java.awt.DefaultKeyboardFocusManager class. 1263 */ 1264 public static DefaultKeyboardFocusManagerAccessor getDefaultKeyboardFocusManagerAccessor() { 1265 if (defaultKeyboardFocusManagerAccessor == null) { 1266 unsafe.ensureClassInitialized(DefaultKeyboardFocusManagerAccessor.class); 1267 } 1268 return defaultKeyboardFocusManagerAccessor; 1269 } 1270 /* 1271 * Set an accessor object for the java.awt.SequencedEvent class. 1272 */ 1273 public static void setSequencedEventAccessor(SequencedEventAccessor sea) { 1274 sequencedEventAccessor = sea; 1275 } 1276 1277 /* 1278 * Get the accessor object for the java.awt.SequencedEvent class. 1279 */ 1280 public static SequencedEventAccessor getSequencedEventAccessor() { 1281 if (sequencedEventAccessor == null) { 1282 try { 1283 unsafe.ensureClassInitialized( 1284 Class.forName("java.awt.SequencedEvent")); 1285 } catch (ClassNotFoundException ignore) { 1286 } 1287 } 1288 return sequencedEventAccessor; 1289 } 1290 1291 /* 1292 * Set an accessor object for the java.awt.Toolkit class. 1293 */ 1294 public static void setToolkitAccessor(ToolkitAccessor ta) { 1295 toolkitAccessor = ta; 1296 } 1297 1298 /* 1299 * Get the accessor object for the java.awt.Toolkit class. 1300 */ 1301 public static ToolkitAccessor getToolkitAccessor() { 1302 if (toolkitAccessor == null) { 1303 unsafe.ensureClassInitialized(Toolkit.class); 1304 } 1305 1306 return toolkitAccessor; 1307 } 1308 1309 /* 1310 * Get the accessor object for the java.awt.event.InvocationEvent class. 1311 */ 1312 public static void setInvocationEventAccessor(InvocationEventAccessor invocationEventAccessor) { 1313 AWTAccessor.invocationEventAccessor = invocationEventAccessor; 1314 } 1315 1316 /* 1317 * Set the accessor object for the java.awt.event.InvocationEvent class. 1318 */ 1319 public static InvocationEventAccessor getInvocationEventAccessor() { 1320 return invocationEventAccessor; 1321 } 1322 1323 /* 1324 * Get the accessor object for the java.awt.SystemColor class. 1325 */ 1326 public static SystemColorAccessor getSystemColorAccessor() { 1327 if (systemColorAccessor == null) { 1328 unsafe.ensureClassInitialized(SystemColor.class); 1329 } 1330 1331 return systemColorAccessor; 1332 } 1333 1334 /* 1335 * Set the accessor object for the java.awt.SystemColor class. 1336 */ 1337 public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) { 1338 AWTAccessor.systemColorAccessor = systemColorAccessor; 1339 } 1340 1341 /* 1342 * Get the accessor object for the javax.accessibility.AccessibleContext class. 1343 */ 1344 public static AccessibleContextAccessor getAccessibleContextAccessor() { 1345 if (accessibleContextAccessor == null) { 1346 unsafe.ensureClassInitialized(AccessibleContext.class); 1347 } 1348 return accessibleContextAccessor; 1349 } 1350 1351 /* 1352 * Set the accessor object for the javax.accessibility.AccessibleBundle class. 1353 */ 1354 public static void setAccessibleBundleAccessor(AccessibleBundleAccessor accessor) { 1355 AWTAccessor.accessibleBundleAccessor = accessor; 1356 } 1357 1358 /* 1359 * Get the accessor object for the javax.accessibility.AccessibleBundle class. 1360 */ 1361 public static AccessibleBundleAccessor getAccessibleBundleAccessor() { 1362 if (accessibleBundleAccessor == null) { 1363 unsafe.ensureClassInitialized(AccessibleBundle.class); 1364 } 1365 return accessibleBundleAccessor; 1366 } 1367 1368 /* 1369 * Set the accessor object for the javax.accessibility.AccessibleContext class. 1370 */ 1371 public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) { 1372 AWTAccessor.accessibleContextAccessor = accessor; 1373 } 1374 1375 /* 1376 * Get the accessor object for the java.awt.dnd.DragSourceContext class. 1377 */ 1378 public static DragSourceContextAccessor getDragSourceContextAccessor() { 1379 if (dragSourceContextAccessor == null) { 1380 unsafe.ensureClassInitialized(DragSourceContext.class); 1381 } 1382 return dragSourceContextAccessor; 1383 } 1384 1385 /* 1386 * Set the accessor object for the java.awt.dnd.DragSourceContext class. 1387 */ 1388 public static void setDragSourceContextAccessor(DragSourceContextAccessor accessor) { 1389 AWTAccessor.dragSourceContextAccessor = accessor; 1390 } 1391 1392 /* 1393 * Get the accessor object for the java.awt.dnd.DropTargetContext class. 1394 */ 1395 public static DropTargetContextAccessor getDropTargetContextAccessor() { 1396 if (dropTargetContextAccessor == null) { 1397 unsafe.ensureClassInitialized(DropTargetContext.class); 1398 } 1399 return dropTargetContextAccessor; 1400 } 1401 1402 /* 1403 * Set the accessor object for the java.awt.dnd.DropTargetContext class. 1404 */ 1405 public static void setDropTargetContextAccessor(DropTargetContextAccessor accessor) { 1406 AWTAccessor.dropTargetContextAccessor = accessor; 1407 } 1408 1409 }