1 /* 2 * Copyright (c) 2008, 2016, 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 * Get opacity level of the given window. 295 */ 296 float getOpacity(Window window); 297 /* 298 * Set opacity level to the given window. 299 */ 300 void setOpacity(Window window, float opacity); 301 /* 302 * Get a shape assigned to the given window. 303 */ 304 Shape getShape(Window window); 305 /* 306 * Set a shape to the given window. 307 */ 308 void setShape(Window window, Shape shape); 309 /* 310 * Set the opaque preoperty to the given window. 311 */ 312 void setOpaque(Window window, boolean isOpaque); 313 /* 314 * Update the image of a non-opaque (translucent) window. 315 */ 316 void updateWindow(Window window); 317 318 /** Get the size of the security warning. 319 */ 320 Dimension getSecurityWarningSize(Window w); 321 322 /** 323 * Set the size of the security warning. 324 */ 325 void setSecurityWarningSize(Window w, int width, int height); 326 327 /** Set the position of the security warning. 328 */ 329 void setSecurityWarningPosition(Window w, Point2D point, 330 float alignmentX, float alignmentY); 331 332 /** Request to recalculate the new position of the security warning for 333 * the given window size/location as reported by the native system. 334 */ 335 Point2D calculateSecurityWarningPosition(Window window, 336 double x, double y, double w, double h); 337 338 /** Sets the synchronous status of focus requests on lightweight 339 * components in the specified window to the specified value. 340 */ 341 void setLWRequestStatus(Window changed, boolean status); 342 343 /** 344 * Indicates whether this window should receive focus on subsequently 345 * being shown, or being moved to the front. 346 */ 347 boolean isAutoRequestFocus(Window w); 348 349 /** 350 * Indicates whether the specified window is an utility window for TrayIcon. 351 */ 352 boolean isTrayIconWindow(Window w); 353 354 /** 355 * Marks the specified window as an utility window for TrayIcon. 356 */ 357 void setTrayIconWindow(Window w, boolean isTrayIconWindow); 358 359 /** 360 * Return an array containing all the windows this 361 * window currently owns. 362 */ 363 Window[] getOwnedWindows(Window w); 364 } 365 366 /** 367 * An accessor for the AWTEvent class. 368 */ 369 public interface AWTEventAccessor { 370 /** 371 * Marks the event as posted. 372 */ 373 void setPosted(AWTEvent ev); 374 375 /** 376 * Sets the flag on this AWTEvent indicating that it was 377 * generated by the system. 378 */ 379 void setSystemGenerated(AWTEvent ev); 380 381 /** 382 * Indicates whether this AWTEvent was generated by the system. 383 */ 384 boolean isSystemGenerated(AWTEvent ev); 385 386 /** 387 * Returns the acc this event was constructed with. 388 */ 389 AccessControlContext getAccessControlContext(AWTEvent ev); 390 391 /** 392 * Returns binary data associated with this event; 393 */ 394 byte[] getBData(AWTEvent ev); 395 396 /** 397 * Associates binary data with this event; 398 */ 399 void setBData(AWTEvent ev, byte[] bdata); 400 } 401 402 public interface InputEventAccessor { 403 /* 404 * Accessor for InputEvent.getButtonDownMasks() 405 */ 406 int[] getButtonDownMasks(); 407 408 /* 409 * Accessor for InputEvent.canAccessSystemClipboard field 410 */ 411 boolean canAccessSystemClipboard(InputEvent event); 412 void setCanAccessSystemClipboard(InputEvent event, 413 boolean canAccessSystemClipboard); 414 } 415 416 /** 417 * An accessor for the MouseEvent class. 418 */ 419 public interface MouseEventAccessor { 420 /** 421 * Indicates whether the event is a result of a touch event. 422 */ 423 boolean isCausedByTouchEvent(MouseEvent ev); 424 425 /** 426 * Sets whether the event is a result of a touch event. 427 */ 428 void setCausedByTouchEvent(MouseEvent ev, boolean causedByTouchEvent); 429 } 430 431 /* 432 * An accessor for the java.awt.Frame class. 433 */ 434 public interface FrameAccessor { 435 /* 436 * Sets the state of this frame. 437 */ 438 void setExtendedState(Frame frame, int state); 439 /* 440 * Gets the state of this frame. 441 */ 442 int getExtendedState(Frame frame); 443 /* 444 * Gets the maximized bounds of this frame. 445 */ 446 Rectangle getMaximizedBounds(Frame frame); 447 } 448 449 /** 450 * An interface of accessor for the java.awt.KeyboardFocusManager class. 451 */ 452 public interface KeyboardFocusManagerAccessor { 453 /** 454 * Indicates whether the native implementation should 455 * proceed with a pending focus request for the heavyweight. 456 */ 457 int shouldNativelyFocusHeavyweight(Component heavyweight, 458 Component descendant, 459 boolean temporary, 460 boolean focusedWindowChangeAllowed, 461 long time, 462 Cause cause); 463 /** 464 * Delivers focus for the lightweight descendant of the heavyweight 465 * synchronously. 466 */ 467 boolean processSynchronousLightweightTransfer(Component heavyweight, 468 Component descendant, 469 boolean temporary, 470 boolean focusedWindowChangeAllowed, 471 long time); 472 /** 473 * Removes the last focus request for the heavyweight from the queue. 474 */ 475 void removeLastFocusRequest(Component heavyweight); 476 477 /** 478 * Gets the most recent focus owner in the window. 479 */ 480 Component getMostRecentFocusOwner(Window window); 481 482 /** 483 * Sets the most recent focus owner in the window. 484 */ 485 void setMostRecentFocusOwner(Window window, Component component); 486 487 /** 488 * Returns current KFM of the specified AppContext. 489 */ 490 KeyboardFocusManager getCurrentKeyboardFocusManager(AppContext ctx); 491 492 /** 493 * Return the current focus cycle root 494 */ 495 Container getCurrentFocusCycleRoot(); 496 } 497 498 /** 499 * An accessor for the MenuComponent class. 500 */ 501 public interface MenuComponentAccessor { 502 /** 503 * Returns the appContext of the menu component. 504 */ 505 AppContext getAppContext(MenuComponent menuComp); 506 507 /** 508 * Sets the appContext of the menu component. 509 */ 510 void setAppContext(MenuComponent menuComp, AppContext appContext); 511 512 /** 513 * Returns the peer of the menu component. 514 */ 515 <T extends MenuComponentPeer> T getPeer(MenuComponent menuComp); 516 517 /** 518 * Returns the menu container of the menu component. 519 */ 520 MenuContainer getParent(MenuComponent menuComp); 521 522 /** 523 * Sets the menu container of the menu component. 524 */ 525 void setParent(MenuComponent menuComp, MenuContainer menuContainer); 526 527 /** 528 * Gets the font used for this menu component. 529 */ 530 Font getFont_NoClientCode(MenuComponent menuComp); 531 } 532 533 /** 534 * An accessor for the EventQueue class 535 */ 536 public interface EventQueueAccessor { 537 /** 538 * Gets the event dispatch thread. 539 */ 540 Thread getDispatchThread(EventQueue eventQueue); 541 542 /** 543 * Checks if the current thread is EDT for the given EQ. 544 */ 545 public boolean isDispatchThreadImpl(EventQueue eventQueue); 546 547 /** 548 * Removes any pending events for the specified source object. 549 */ 550 void removeSourceEvents(EventQueue eventQueue, Object source, boolean removeAllEvents); 551 552 /** 553 * Returns whether an event is pending on any of the separate Queues. 554 */ 555 boolean noEvents(EventQueue eventQueue); 556 557 /** 558 * Called from PostEventQueue.postEvent to notify that a new event 559 * appeared. 560 */ 561 void wakeup(EventQueue eventQueue, boolean isShutdown); 562 563 /** 564 * Static in EventQueue 565 */ 566 void invokeAndWait(Object source, Runnable r) 567 throws InterruptedException, InvocationTargetException; 568 569 /** 570 * Sets the delegate for the EventQueue used by FX/AWT single threaded mode 571 */ 572 void setFwDispatcher(EventQueue eventQueue, FwDispatcher dispatcher); 573 574 /** 575 * Gets most recent event time in the EventQueue 576 */ 577 long getMostRecentEventTime(EventQueue eventQueue); 578 } 579 580 /* 581 * An accessor for the PopupMenu class 582 */ 583 public interface PopupMenuAccessor { 584 /* 585 * Returns whether the popup menu is attached to a tray 586 */ 587 boolean isTrayIconPopup(PopupMenu popupMenu); 588 } 589 590 /* 591 * An accessor for the FileDialog class 592 */ 593 public interface FileDialogAccessor { 594 /* 595 * Sets the files the user selects 596 */ 597 void setFiles(FileDialog fileDialog, File files[]); 598 599 /* 600 * Sets the file the user selects 601 */ 602 void setFile(FileDialog fileDialog, String file); 603 604 /* 605 * Sets the directory the user selects 606 */ 607 void setDirectory(FileDialog fileDialog, String directory); 608 609 /* 610 * Returns whether the file dialog allows the multiple file selection. 611 */ 612 boolean isMultipleMode(FileDialog fileDialog); 613 } 614 615 /* 616 * An accessor for the ScrollPaneAdjustable class. 617 */ 618 public interface ScrollPaneAdjustableAccessor { 619 /* 620 * Sets the value of this scrollbar to the specified value. 621 */ 622 void setTypedValue(final ScrollPaneAdjustable adj, final int v, 623 final int type); 624 } 625 626 /** 627 * An accessor for the CheckboxMenuItem class 628 */ 629 public interface CheckboxMenuItemAccessor { 630 /** 631 * Returns whether menu item is checked 632 */ 633 boolean getState(CheckboxMenuItem cmi); 634 } 635 636 /** 637 * An accessor for the Cursor class 638 */ 639 public interface CursorAccessor { 640 /** 641 * Returns pData of the Cursor class 642 */ 643 long getPData(Cursor cursor); 644 645 /** 646 * Sets pData to the Cursor class 647 */ 648 void setPData(Cursor cursor, long pData); 649 650 /** 651 * Return type of the Cursor class 652 */ 653 int getType(Cursor cursor); 654 } 655 656 /** 657 * An accessor for the MenuBar class 658 */ 659 public interface MenuBarAccessor { 660 /** 661 * Returns help menu 662 */ 663 Menu getHelpMenu(MenuBar menuBar); 664 665 /** 666 * Returns menus 667 */ 668 Vector<Menu> getMenus(MenuBar menuBar); 669 } 670 671 /** 672 * An accessor for the MenuItem class 673 */ 674 public interface MenuItemAccessor { 675 /** 676 * Returns whether menu item is enabled 677 */ 678 boolean isEnabled(MenuItem item); 679 680 /** 681 * Gets the command name of the action event that is fired 682 * by this menu item. 683 */ 684 String getActionCommandImpl(MenuItem item); 685 686 /** 687 * Returns true if the item and all its ancestors are 688 * enabled, false otherwise 689 */ 690 boolean isItemEnabled(MenuItem item); 691 692 /** 693 * Returns label 694 */ 695 String getLabel(MenuItem item); 696 697 /** 698 * Returns shortcut 699 */ 700 MenuShortcut getShortcut(MenuItem item); 701 } 702 703 /** 704 * An accessor for the Menu class 705 */ 706 public interface MenuAccessor { 707 /** 708 * Returns vector of the items that are part of the Menu 709 */ 710 Vector<MenuItem> getItems(Menu menu); 711 } 712 713 /** 714 * An accessor for the KeyEvent class 715 */ 716 public interface KeyEventAccessor { 717 /** 718 * Sets rawCode field for KeyEvent 719 */ 720 void setRawCode(KeyEvent ev, long rawCode); 721 722 /** 723 * Sets primaryLevelUnicode field for KeyEvent 724 */ 725 void setPrimaryLevelUnicode(KeyEvent ev, long primaryLevelUnicode); 726 727 /** 728 * Sets extendedKeyCode field for KeyEvent 729 */ 730 void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode); 731 732 /** 733 * Gets original source for KeyEvent 734 */ 735 Component getOriginalSource(KeyEvent ev); 736 737 /** 738 * Gets isProxyActive field for KeyEvent 739 */ 740 boolean isProxyActive(KeyEvent ev); 741 } 742 743 /** 744 * An accessor for the ClientPropertyKey class 745 */ 746 public interface ClientPropertyKeyAccessor { 747 /** 748 * Retrieves JComponent_TRANSFER_HANDLER enum object 749 */ 750 Object getJComponent_TRANSFER_HANDLER(); 751 } 752 753 /** 754 * An accessor for the SystemTray class 755 */ 756 public interface SystemTrayAccessor { 757 /** 758 * Support for reporting bound property changes for Object properties. 759 */ 760 void firePropertyChange(SystemTray tray, String propertyName, Object oldValue, Object newValue); 761 } 762 763 /** 764 * An accessor for the TrayIcon class 765 */ 766 public interface TrayIconAccessor { 767 void addNotify(TrayIcon trayIcon) throws AWTException; 768 void removeNotify(TrayIcon trayIcon); 769 } 770 771 /** 772 * An accessor for the DefaultKeyboardFocusManager class 773 */ 774 public interface DefaultKeyboardFocusManagerAccessor { 775 public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e); 776 } 777 778 /* 779 * An accessor for the SequencedEventAccessor class 780 */ 781 public interface SequencedEventAccessor { 782 /* 783 * Returns the nested event. 784 */ 785 AWTEvent getNested(AWTEvent sequencedEvent); 786 787 /* 788 * Returns true if the event is an instances of SequencedEvent. 789 */ 790 boolean isSequencedEvent(AWTEvent event); 791 792 /* 793 * Creates SequencedEvent with the given nested event 794 */ 795 AWTEvent create(AWTEvent event); 796 } 797 798 /* 799 * An accessor for the Toolkit class 800 */ 801 public interface ToolkitAccessor { 802 void setPlatformResources(ResourceBundle bundle); 803 } 804 805 /* 806 * An accessor object for the InvocationEvent class 807 */ 808 public interface InvocationEventAccessor { 809 void dispose(InvocationEvent event); 810 } 811 812 /* 813 * An accessor object for the SystemColor class 814 */ 815 public interface SystemColorAccessor { 816 void updateSystemColors(); 817 } 818 819 /* 820 * An accessor object for the AccessibleContext class 821 */ 822 public interface AccessibleContextAccessor { 823 void setAppContext(AccessibleContext accessibleContext, AppContext appContext); 824 AppContext getAppContext(AccessibleContext accessibleContext); 825 Object getNativeAXResource(AccessibleContext accessibleContext); 826 void setNativeAXResource(AccessibleContext accessibleContext, Object value); 827 } 828 829 /* 830 * An accessor object for the AccessibleContext class 831 */ 832 public interface AccessibleBundleAccessor { 833 String getKey(AccessibleBundle accessibleBundle); 834 } 835 836 /* 837 * An accessor object for the DragSourceContext class 838 */ 839 public interface DragSourceContextAccessor { 840 /** 841 * Returns the peer of the DragSourceContext. 842 */ 843 DragSourceContextPeer getPeer(DragSourceContext dsc); 844 } 845 846 /* 847 * An accessor object for the DropTargetContext class 848 */ 849 public interface DropTargetContextAccessor { 850 /** 851 * Resets the DropTargetContext. 852 */ 853 void reset(DropTargetContext dtc); 854 /** 855 * Sets the {@code DropTargetContextPeer} 856 */ 857 void setDropTargetContextPeer(DropTargetContext dtc, 858 DropTargetContextPeer dtcp); 859 } 860 861 /* 862 * Accessor instances are initialized in the static initializers of 863 * corresponding AWT classes by using setters defined below. 864 */ 865 private static ComponentAccessor componentAccessor; 866 private static ContainerAccessor containerAccessor; 867 private static WindowAccessor windowAccessor; 868 private static AWTEventAccessor awtEventAccessor; 869 private static InputEventAccessor inputEventAccessor; 870 private static MouseEventAccessor mouseEventAccessor; 871 private static FrameAccessor frameAccessor; 872 private static KeyboardFocusManagerAccessor kfmAccessor; 873 private static MenuComponentAccessor menuComponentAccessor; 874 private static EventQueueAccessor eventQueueAccessor; 875 private static PopupMenuAccessor popupMenuAccessor; 876 private static FileDialogAccessor fileDialogAccessor; 877 private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor; 878 private static CheckboxMenuItemAccessor checkboxMenuItemAccessor; 879 private static CursorAccessor cursorAccessor; 880 private static MenuBarAccessor menuBarAccessor; 881 private static MenuItemAccessor menuItemAccessor; 882 private static MenuAccessor menuAccessor; 883 private static KeyEventAccessor keyEventAccessor; 884 private static ClientPropertyKeyAccessor clientPropertyKeyAccessor; 885 private static SystemTrayAccessor systemTrayAccessor; 886 private static TrayIconAccessor trayIconAccessor; 887 private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor; 888 private static SequencedEventAccessor sequencedEventAccessor; 889 private static ToolkitAccessor toolkitAccessor; 890 private static InvocationEventAccessor invocationEventAccessor; 891 private static SystemColorAccessor systemColorAccessor; 892 private static AccessibleContextAccessor accessibleContextAccessor; 893 private static AccessibleBundleAccessor accessibleBundleAccessor; 894 private static DragSourceContextAccessor dragSourceContextAccessor; 895 private static DropTargetContextAccessor dropTargetContextAccessor; 896 897 /* 898 * Set an accessor object for the java.awt.Component class. 899 */ 900 public static void setComponentAccessor(ComponentAccessor ca) { 901 componentAccessor = ca; 902 } 903 904 /* 905 * Retrieve the accessor object for the java.awt.Component class. 906 */ 907 public static ComponentAccessor getComponentAccessor() { 908 if (componentAccessor == null) { 909 unsafe.ensureClassInitialized(Component.class); 910 } 911 912 return componentAccessor; 913 } 914 915 /* 916 * Set an accessor object for the java.awt.Container class. 917 */ 918 public static void setContainerAccessor(ContainerAccessor ca) { 919 containerAccessor = ca; 920 } 921 922 /* 923 * Retrieve the accessor object for the java.awt.Container class. 924 */ 925 public static ContainerAccessor getContainerAccessor() { 926 if (containerAccessor == null) { 927 unsafe.ensureClassInitialized(Container.class); 928 } 929 930 return containerAccessor; 931 } 932 933 /* 934 * Set an accessor object for the java.awt.Window class. 935 */ 936 public static void setWindowAccessor(WindowAccessor wa) { 937 windowAccessor = wa; 938 } 939 940 /* 941 * Retrieve the accessor object for the java.awt.Window class. 942 */ 943 public static WindowAccessor getWindowAccessor() { 944 if (windowAccessor == null) { 945 unsafe.ensureClassInitialized(Window.class); 946 } 947 return windowAccessor; 948 } 949 950 /* 951 * Set an accessor object for the java.awt.AWTEvent class. 952 */ 953 public static void setAWTEventAccessor(AWTEventAccessor aea) { 954 awtEventAccessor = aea; 955 } 956 957 /* 958 * Retrieve the accessor object for the java.awt.AWTEvent class. 959 */ 960 public static AWTEventAccessor getAWTEventAccessor() { 961 if (awtEventAccessor == null) { 962 unsafe.ensureClassInitialized(AWTEvent.class); 963 } 964 return awtEventAccessor; 965 } 966 967 /* 968 * Set an accessor object for the java.awt.event.InputEvent class. 969 */ 970 public static void setInputEventAccessor(InputEventAccessor iea) { 971 inputEventAccessor = iea; 972 } 973 974 /* 975 * Retrieve the accessor object for the java.awt.event.InputEvent class. 976 */ 977 public static InputEventAccessor getInputEventAccessor() { 978 if (inputEventAccessor == null) { 979 unsafe.ensureClassInitialized(InputEvent.class); 980 } 981 return inputEventAccessor; 982 } 983 984 /* 985 * Set an accessor object for the java.awt.event.MouseEvent class. 986 */ 987 public static void setMouseEventAccessor(MouseEventAccessor mea) { 988 mouseEventAccessor = mea; 989 } 990 991 /* 992 * Retrieve the accessor object for the java.awt.event.MouseEvent class. 993 */ 994 public static MouseEventAccessor getMouseEventAccessor() { 995 if (mouseEventAccessor == null) { 996 unsafe.ensureClassInitialized(MouseEvent.class); 997 } 998 return mouseEventAccessor; 999 } 1000 1001 /* 1002 * Set an accessor object for the java.awt.Frame class. 1003 */ 1004 public static void setFrameAccessor(FrameAccessor fa) { 1005 frameAccessor = fa; 1006 } 1007 1008 /* 1009 * Retrieve the accessor object for the java.awt.Frame class. 1010 */ 1011 public static FrameAccessor getFrameAccessor() { 1012 if (frameAccessor == null) { 1013 unsafe.ensureClassInitialized(Frame.class); 1014 } 1015 return frameAccessor; 1016 } 1017 1018 /* 1019 * Set an accessor object for the java.awt.KeyboardFocusManager class. 1020 */ 1021 public static void setKeyboardFocusManagerAccessor(KeyboardFocusManagerAccessor kfma) { 1022 kfmAccessor = kfma; 1023 } 1024 1025 /* 1026 * Retrieve the accessor object for the java.awt.KeyboardFocusManager class. 1027 */ 1028 public static KeyboardFocusManagerAccessor getKeyboardFocusManagerAccessor() { 1029 if (kfmAccessor == null) { 1030 unsafe.ensureClassInitialized(KeyboardFocusManager.class); 1031 } 1032 return kfmAccessor; 1033 } 1034 1035 /* 1036 * Set an accessor object for the java.awt.MenuComponent class. 1037 */ 1038 public static void setMenuComponentAccessor(MenuComponentAccessor mca) { 1039 menuComponentAccessor = mca; 1040 } 1041 1042 /* 1043 * Retrieve the accessor object for the java.awt.MenuComponent class. 1044 */ 1045 public static MenuComponentAccessor getMenuComponentAccessor() { 1046 if (menuComponentAccessor == null) { 1047 unsafe.ensureClassInitialized(MenuComponent.class); 1048 } 1049 return menuComponentAccessor; 1050 } 1051 1052 /* 1053 * Set an accessor object for the java.awt.EventQueue class. 1054 */ 1055 public static void setEventQueueAccessor(EventQueueAccessor eqa) { 1056 eventQueueAccessor = eqa; 1057 } 1058 1059 /* 1060 * Retrieve the accessor object for the java.awt.EventQueue class. 1061 */ 1062 public static EventQueueAccessor getEventQueueAccessor() { 1063 if (eventQueueAccessor == null) { 1064 unsafe.ensureClassInitialized(EventQueue.class); 1065 } 1066 return eventQueueAccessor; 1067 } 1068 1069 /* 1070 * Set an accessor object for the java.awt.PopupMenu class. 1071 */ 1072 public static void setPopupMenuAccessor(PopupMenuAccessor pma) { 1073 popupMenuAccessor = pma; 1074 } 1075 1076 /* 1077 * Retrieve the accessor object for the java.awt.PopupMenu class. 1078 */ 1079 public static PopupMenuAccessor getPopupMenuAccessor() { 1080 if (popupMenuAccessor == null) { 1081 unsafe.ensureClassInitialized(PopupMenu.class); 1082 } 1083 return popupMenuAccessor; 1084 } 1085 1086 /* 1087 * Set an accessor object for the java.awt.FileDialog class. 1088 */ 1089 public static void setFileDialogAccessor(FileDialogAccessor fda) { 1090 fileDialogAccessor = fda; 1091 } 1092 1093 /* 1094 * Retrieve the accessor object for the java.awt.FileDialog class. 1095 */ 1096 public static FileDialogAccessor getFileDialogAccessor() { 1097 if (fileDialogAccessor == null) { 1098 unsafe.ensureClassInitialized(FileDialog.class); 1099 } 1100 return fileDialogAccessor; 1101 } 1102 1103 /* 1104 * Set an accessor object for the java.awt.ScrollPaneAdjustable class. 1105 */ 1106 public static void setScrollPaneAdjustableAccessor(ScrollPaneAdjustableAccessor adj) { 1107 scrollPaneAdjustableAccessor = adj; 1108 } 1109 1110 /* 1111 * Retrieve the accessor object for the java.awt.ScrollPaneAdjustable 1112 * class. 1113 */ 1114 public static ScrollPaneAdjustableAccessor getScrollPaneAdjustableAccessor() { 1115 if (scrollPaneAdjustableAccessor == null) { 1116 unsafe.ensureClassInitialized(ScrollPaneAdjustable.class); 1117 } 1118 return scrollPaneAdjustableAccessor; 1119 } 1120 1121 /** 1122 * Set an accessor object for the java.awt.CheckboxMenuItem class. 1123 */ 1124 public static void setCheckboxMenuItemAccessor(CheckboxMenuItemAccessor cmia) { 1125 checkboxMenuItemAccessor = cmia; 1126 } 1127 1128 /** 1129 * Retrieve the accessor object for the java.awt.CheckboxMenuItem class. 1130 */ 1131 public static CheckboxMenuItemAccessor getCheckboxMenuItemAccessor() { 1132 if (checkboxMenuItemAccessor == null) { 1133 unsafe.ensureClassInitialized(CheckboxMenuItemAccessor.class); 1134 } 1135 return checkboxMenuItemAccessor; 1136 } 1137 1138 /** 1139 * Set an accessor object for the java.awt.Cursor class. 1140 */ 1141 public static void setCursorAccessor(CursorAccessor ca) { 1142 cursorAccessor = ca; 1143 } 1144 1145 /** 1146 * Retrieve the accessor object for the java.awt.Cursor class. 1147 */ 1148 public static CursorAccessor getCursorAccessor() { 1149 if (cursorAccessor == null) { 1150 unsafe.ensureClassInitialized(CursorAccessor.class); 1151 } 1152 return cursorAccessor; 1153 } 1154 1155 /** 1156 * Set an accessor object for the java.awt.MenuBar class. 1157 */ 1158 public static void setMenuBarAccessor(MenuBarAccessor mba) { 1159 menuBarAccessor = mba; 1160 } 1161 1162 /** 1163 * Retrieve the accessor object for the java.awt.MenuBar class. 1164 */ 1165 public static MenuBarAccessor getMenuBarAccessor() { 1166 if (menuBarAccessor == null) { 1167 unsafe.ensureClassInitialized(MenuBarAccessor.class); 1168 } 1169 return menuBarAccessor; 1170 } 1171 1172 /** 1173 * Set an accessor object for the java.awt.MenuItem class. 1174 */ 1175 public static void setMenuItemAccessor(MenuItemAccessor mia) { 1176 menuItemAccessor = mia; 1177 } 1178 1179 /** 1180 * Retrieve the accessor object for the java.awt.MenuItem class. 1181 */ 1182 public static MenuItemAccessor getMenuItemAccessor() { 1183 if (menuItemAccessor == null) { 1184 unsafe.ensureClassInitialized(MenuItemAccessor.class); 1185 } 1186 return menuItemAccessor; 1187 } 1188 1189 /** 1190 * Set an accessor object for the java.awt.Menu class. 1191 */ 1192 public static void setMenuAccessor(MenuAccessor ma) { 1193 menuAccessor = ma; 1194 } 1195 1196 /** 1197 * Retrieve the accessor object for the java.awt.Menu class. 1198 */ 1199 public static MenuAccessor getMenuAccessor() { 1200 if (menuAccessor == null) { 1201 unsafe.ensureClassInitialized(MenuAccessor.class); 1202 } 1203 return menuAccessor; 1204 } 1205 1206 /** 1207 * Set an accessor object for the java.awt.event.KeyEvent class. 1208 */ 1209 public static void setKeyEventAccessor(KeyEventAccessor kea) { 1210 keyEventAccessor = kea; 1211 } 1212 1213 /** 1214 * Retrieve the accessor object for the java.awt.event.KeyEvent class. 1215 */ 1216 public static KeyEventAccessor getKeyEventAccessor() { 1217 if (keyEventAccessor == null) { 1218 unsafe.ensureClassInitialized(KeyEventAccessor.class); 1219 } 1220 return keyEventAccessor; 1221 } 1222 1223 /** 1224 * Set an accessor object for the javax.swing.ClientPropertyKey class. 1225 */ 1226 public static void setClientPropertyKeyAccessor(ClientPropertyKeyAccessor cpka) { 1227 clientPropertyKeyAccessor = cpka; 1228 } 1229 1230 /** 1231 * Retrieve the accessor object for the javax.swing.ClientPropertyKey class. 1232 */ 1233 public static ClientPropertyKeyAccessor getClientPropertyKeyAccessor() { 1234 if (clientPropertyKeyAccessor == null) { 1235 unsafe.ensureClassInitialized(ClientPropertyKeyAccessor.class); 1236 } 1237 return clientPropertyKeyAccessor; 1238 } 1239 1240 /** 1241 * Set an accessor object for the java.awt.SystemTray class. 1242 */ 1243 public static void setSystemTrayAccessor(SystemTrayAccessor sta) { 1244 systemTrayAccessor = sta; 1245 } 1246 1247 /** 1248 * Retrieve the accessor object for the java.awt.SystemTray class. 1249 */ 1250 public static SystemTrayAccessor getSystemTrayAccessor() { 1251 if (systemTrayAccessor == null) { 1252 unsafe.ensureClassInitialized(SystemTrayAccessor.class); 1253 } 1254 return systemTrayAccessor; 1255 } 1256 1257 /** 1258 * Set an accessor object for the java.awt.TrayIcon class. 1259 */ 1260 public static void setTrayIconAccessor(TrayIconAccessor tia) { 1261 trayIconAccessor = tia; 1262 } 1263 1264 /** 1265 * Retrieve the accessor object for the java.awt.TrayIcon class. 1266 */ 1267 public static TrayIconAccessor getTrayIconAccessor() { 1268 if (trayIconAccessor == null) { 1269 unsafe.ensureClassInitialized(TrayIconAccessor.class); 1270 } 1271 return trayIconAccessor; 1272 } 1273 1274 /** 1275 * Set an accessor object for the java.awt.DefaultKeyboardFocusManager class. 1276 */ 1277 public static void setDefaultKeyboardFocusManagerAccessor(DefaultKeyboardFocusManagerAccessor dkfma) { 1278 defaultKeyboardFocusManagerAccessor = dkfma; 1279 } 1280 1281 /** 1282 * Retrieve the accessor object for the java.awt.DefaultKeyboardFocusManager class. 1283 */ 1284 public static DefaultKeyboardFocusManagerAccessor getDefaultKeyboardFocusManagerAccessor() { 1285 if (defaultKeyboardFocusManagerAccessor == null) { 1286 unsafe.ensureClassInitialized(DefaultKeyboardFocusManagerAccessor.class); 1287 } 1288 return defaultKeyboardFocusManagerAccessor; 1289 } 1290 /* 1291 * Set an accessor object for the java.awt.SequencedEvent class. 1292 */ 1293 public static void setSequencedEventAccessor(SequencedEventAccessor sea) { 1294 sequencedEventAccessor = sea; 1295 } 1296 1297 /* 1298 * Get the accessor object for the java.awt.SequencedEvent class. 1299 */ 1300 public static SequencedEventAccessor getSequencedEventAccessor() { 1301 if (sequencedEventAccessor == null) { 1302 try { 1303 unsafe.ensureClassInitialized( 1304 Class.forName("java.awt.SequencedEvent")); 1305 } catch (ClassNotFoundException ignore) { 1306 } 1307 } 1308 return sequencedEventAccessor; 1309 } 1310 1311 /* 1312 * Set an accessor object for the java.awt.Toolkit class. 1313 */ 1314 public static void setToolkitAccessor(ToolkitAccessor ta) { 1315 toolkitAccessor = ta; 1316 } 1317 1318 /* 1319 * Get the accessor object for the java.awt.Toolkit class. 1320 */ 1321 public static ToolkitAccessor getToolkitAccessor() { 1322 if (toolkitAccessor == null) { 1323 unsafe.ensureClassInitialized(Toolkit.class); 1324 } 1325 1326 return toolkitAccessor; 1327 } 1328 1329 /* 1330 * Get the accessor object for the java.awt.event.InvocationEvent class. 1331 */ 1332 public static void setInvocationEventAccessor(InvocationEventAccessor invocationEventAccessor) { 1333 AWTAccessor.invocationEventAccessor = invocationEventAccessor; 1334 } 1335 1336 /* 1337 * Set the accessor object for the java.awt.event.InvocationEvent class. 1338 */ 1339 public static InvocationEventAccessor getInvocationEventAccessor() { 1340 return invocationEventAccessor; 1341 } 1342 1343 /* 1344 * Get the accessor object for the java.awt.SystemColor class. 1345 */ 1346 public static SystemColorAccessor getSystemColorAccessor() { 1347 if (systemColorAccessor == null) { 1348 unsafe.ensureClassInitialized(SystemColor.class); 1349 } 1350 1351 return systemColorAccessor; 1352 } 1353 1354 /* 1355 * Set the accessor object for the java.awt.SystemColor class. 1356 */ 1357 public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) { 1358 AWTAccessor.systemColorAccessor = systemColorAccessor; 1359 } 1360 1361 /* 1362 * Get the accessor object for the javax.accessibility.AccessibleContext class. 1363 */ 1364 public static AccessibleContextAccessor getAccessibleContextAccessor() { 1365 if (accessibleContextAccessor == null) { 1366 unsafe.ensureClassInitialized(AccessibleContext.class); 1367 } 1368 return accessibleContextAccessor; 1369 } 1370 1371 /* 1372 * Set the accessor object for the javax.accessibility.AccessibleBundle class. 1373 */ 1374 public static void setAccessibleBundleAccessor(AccessibleBundleAccessor accessor) { 1375 AWTAccessor.accessibleBundleAccessor = accessor; 1376 } 1377 1378 /* 1379 * Get the accessor object for the javax.accessibility.AccessibleBundle class. 1380 */ 1381 public static AccessibleBundleAccessor getAccessibleBundleAccessor() { 1382 if (accessibleBundleAccessor == null) { 1383 unsafe.ensureClassInitialized(AccessibleBundle.class); 1384 } 1385 return accessibleBundleAccessor; 1386 } 1387 1388 /* 1389 * Set the accessor object for the javax.accessibility.AccessibleContext class. 1390 */ 1391 public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) { 1392 AWTAccessor.accessibleContextAccessor = accessor; 1393 } 1394 1395 /* 1396 * Get the accessor object for the java.awt.dnd.DragSourceContext class. 1397 */ 1398 public static DragSourceContextAccessor getDragSourceContextAccessor() { 1399 if (dragSourceContextAccessor == null) { 1400 unsafe.ensureClassInitialized(DragSourceContext.class); 1401 } 1402 return dragSourceContextAccessor; 1403 } 1404 1405 /* 1406 * Set the accessor object for the java.awt.dnd.DragSourceContext class. 1407 */ 1408 public static void setDragSourceContextAccessor(DragSourceContextAccessor accessor) { 1409 AWTAccessor.dragSourceContextAccessor = accessor; 1410 } 1411 1412 /* 1413 * Get the accessor object for the java.awt.dnd.DropTargetContext class. 1414 */ 1415 public static DropTargetContextAccessor getDropTargetContextAccessor() { 1416 if (dropTargetContextAccessor == null) { 1417 unsafe.ensureClassInitialized(DropTargetContext.class); 1418 } 1419 return dropTargetContextAccessor; 1420 } 1421 1422 /* 1423 * Set the accessor object for the java.awt.dnd.DropTargetContext class. 1424 */ 1425 public static void setDropTargetContextAccessor(DropTargetContextAccessor accessor) { 1426 AWTAccessor.dropTargetContextAccessor = accessor; 1427 } 1428 1429 }