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