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