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