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