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 public void setFwDispatcher(EventQueue eventQueue, FwDispatcher dispatcher); 534 } 535 536 /* 537 * An accessor for the PopupMenu class 538 */ 539 public interface PopupMenuAccessor { 540 /* 541 * Returns whether the popup menu is attached to a tray 542 */ 543 boolean isTrayIconPopup(PopupMenu popupMenu); 544 } 545 546 /* 547 * An accessor for the FileDialog class 548 */ 549 public interface FileDialogAccessor { 550 /* 551 * Sets the files the user selects 552 */ 553 void setFiles(FileDialog fileDialog, File files[]); 554 555 /* 556 * Sets the file the user selects 557 */ 558 void setFile(FileDialog fileDialog, String file); 559 560 /* 561 * Sets the directory the user selects 562 */ 563 void setDirectory(FileDialog fileDialog, String directory); 564 565 /* 566 * Returns whether the file dialog allows the multiple file selection. 567 */ 568 boolean isMultipleMode(FileDialog fileDialog); 569 } 570 571 /* 572 * An accessor for the ScrollPaneAdjustable class. 573 */ 574 public interface ScrollPaneAdjustableAccessor { 575 /* 576 * Sets the value of this scrollbar to the specified value. 577 */ 578 void setTypedValue(final ScrollPaneAdjustable adj, final int v, 579 final int type); 580 } 581 582 /** 583 * An accessor for the CheckboxMenuItem class 584 */ 585 public interface CheckboxMenuItemAccessor { 586 /** 587 * Returns whether menu item is checked 588 */ 589 boolean getState(CheckboxMenuItem cmi); 590 } 591 592 /** 593 * An accessor for the Cursor class 594 */ 595 public interface CursorAccessor { 596 /** 597 * Returns pData of the Cursor class 598 */ 599 long getPData(Cursor cursor); 600 601 /** 602 * Sets pData to the Cursor class 603 */ 604 void setPData(Cursor cursor, long pData); 605 606 /** 607 * Return type of the Cursor class 608 */ 609 int getType(Cursor cursor); 610 } 611 612 /** 613 * An accessor for the MenuBar class 614 */ 615 public interface MenuBarAccessor { 616 /** 617 * Returns help menu 618 */ 619 Menu getHelpMenu(MenuBar menuBar); 620 621 /** 622 * Returns menus 623 */ 624 Vector<Menu> getMenus(MenuBar menuBar); 625 } 626 627 /** 628 * An accessor for the MenuItem class 629 */ 630 public interface MenuItemAccessor { 631 /** 632 * Returns whether menu item is enabled 633 */ 634 boolean isEnabled(MenuItem item); 635 636 /** 637 * Gets the command name of the action event that is fired 638 * by this menu item. 639 */ 640 String getActionCommandImpl(MenuItem item); 641 642 /** 643 * Returns true if the item and all its ancestors are 644 * enabled, false otherwise 645 */ 646 boolean isItemEnabled(MenuItem item); 647 648 /** 649 * Returns label 650 */ 651 String getLabel(MenuItem item); 652 653 /** 654 * Returns shortcut 655 */ 656 MenuShortcut getShortcut(MenuItem item); 657 } 658 659 /** 660 * An accessor for the Menu class 661 */ 662 public interface MenuAccessor { 663 /** 664 * Returns vector of the items that are part of the Menu 665 */ 666 Vector<MenuItem> getItems(Menu menu); 667 } 668 669 /** 670 * An accessor for the KeyEvent class 671 */ 672 public interface KeyEventAccessor { 673 /** 674 * Sets rawCode field for KeyEvent 675 */ 676 void setRawCode(KeyEvent ev, long rawCode); 677 678 /** 679 * Sets primaryLevelUnicode field for KeyEvent 680 */ 681 void setPrimaryLevelUnicode(KeyEvent ev, long primaryLevelUnicode); 682 683 /** 684 * Sets extendedKeyCode field for KeyEvent 685 */ 686 void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode); 687 688 /** 689 * Gets original source for KeyEvent 690 */ 691 Component getOriginalSource(KeyEvent ev); 692 } 693 694 /** 695 * An accessor for the ClientPropertyKey class 696 */ 697 public interface ClientPropertyKeyAccessor { 698 /** 699 * Retrieves JComponent_TRANSFER_HANDLER enum object 700 */ 701 Object getJComponent_TRANSFER_HANDLER(); 702 } 703 704 /** 705 * An accessor for the SystemTray class 706 */ 707 public interface SystemTrayAccessor { 708 /** 709 * Support for reporting bound property changes for Object properties. 710 */ 711 void firePropertyChange(SystemTray tray, String propertyName, Object oldValue, Object newValue); 712 } 713 714 /** 715 * An accessor for the TrayIcon class 716 */ 717 public interface TrayIconAccessor { 718 void addNotify(TrayIcon trayIcon) throws AWTException; 719 void removeNotify(TrayIcon trayIcon); 720 } 721 722 /** 723 * An accessor for the DefaultKeyboardFocusManager class 724 */ 725 public interface DefaultKeyboardFocusManagerAccessor { 726 public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e); 727 } 728 729 /* 730 * An accessor for the SequencedEventAccessor class 731 */ 732 public interface SequencedEventAccessor { 733 /* 734 * Returns the nested event. 735 */ 736 AWTEvent getNested(AWTEvent sequencedEvent); 737 738 /* 739 * Returns true if the event is an instances of SequencedEvent. 740 */ 741 boolean isSequencedEvent(AWTEvent event); 742 } 743 744 /* 745 * An accessor for the Toolkit class 746 */ 747 public interface ToolkitAccessor { 748 void setPlatformResources(ResourceBundle bundle); 749 } 750 751 /* 752 * An accessor object for the InvocationEvent class 753 */ 754 public interface InvocationEventAccessor { 755 void dispose(InvocationEvent event); 756 } 757 758 /* 759 * An accessor object for the SystemColor class 760 */ 761 public interface SystemColorAccessor { 762 void updateSystemColors(); 763 } 764 765 /* 766 * An accessor object for the AccessibleContext class 767 */ 768 public interface AccessibleContextAccessor { 769 void setAppContext(AccessibleContext accessibleContext, AppContext appContext); 770 AppContext getAppContext(AccessibleContext accessibleContext); 771 } 772 773 /* 774 * Accessor instances are initialized in the static initializers of 775 * corresponding AWT classes by using setters defined below. 776 */ 777 private static ComponentAccessor componentAccessor; 778 private static ContainerAccessor containerAccessor; 779 private static WindowAccessor windowAccessor; 780 private static AWTEventAccessor awtEventAccessor; 781 private static InputEventAccessor inputEventAccessor; 782 private static FrameAccessor frameAccessor; 783 private static KeyboardFocusManagerAccessor kfmAccessor; 784 private static MenuComponentAccessor menuComponentAccessor; 785 private static EventQueueAccessor eventQueueAccessor; 786 private static PopupMenuAccessor popupMenuAccessor; 787 private static FileDialogAccessor fileDialogAccessor; 788 private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor; 789 private static CheckboxMenuItemAccessor checkboxMenuItemAccessor; 790 private static CursorAccessor cursorAccessor; 791 private static MenuBarAccessor menuBarAccessor; 792 private static MenuItemAccessor menuItemAccessor; 793 private static MenuAccessor menuAccessor; 794 private static KeyEventAccessor keyEventAccessor; 795 private static ClientPropertyKeyAccessor clientPropertyKeyAccessor; 796 private static SystemTrayAccessor systemTrayAccessor; 797 private static TrayIconAccessor trayIconAccessor; 798 private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor; 799 private static SequencedEventAccessor sequencedEventAccessor; 800 private static ToolkitAccessor toolkitAccessor; 801 private static InvocationEventAccessor invocationEventAccessor; 802 private static SystemColorAccessor systemColorAccessor; 803 private static AccessibleContextAccessor accessibleContextAccessor; 804 805 /* 806 * Set an accessor object for the java.awt.Component class. 807 */ 808 public static void setComponentAccessor(ComponentAccessor ca) { 809 componentAccessor = ca; 810 } 811 812 /* 813 * Retrieve the accessor object for the java.awt.Component class. 814 */ 815 public static ComponentAccessor getComponentAccessor() { 816 if (componentAccessor == null) { 817 unsafe.ensureClassInitialized(Component.class); 818 } 819 820 return componentAccessor; 821 } 822 823 /* 824 * Set an accessor object for the java.awt.Container class. 825 */ 826 public static void setContainerAccessor(ContainerAccessor ca) { 827 containerAccessor = ca; 828 } 829 830 /* 831 * Retrieve the accessor object for the java.awt.Container class. 832 */ 833 public static ContainerAccessor getContainerAccessor() { 834 if (containerAccessor == null) { 835 unsafe.ensureClassInitialized(Container.class); 836 } 837 838 return containerAccessor; 839 } 840 841 /* 842 * Set an accessor object for the java.awt.Window class. 843 */ 844 public static void setWindowAccessor(WindowAccessor wa) { 845 windowAccessor = wa; 846 } 847 848 /* 849 * Retrieve the accessor object for the java.awt.Window class. 850 */ 851 public static WindowAccessor getWindowAccessor() { 852 if (windowAccessor == null) { 853 unsafe.ensureClassInitialized(Window.class); 854 } 855 return windowAccessor; 856 } 857 858 /* 859 * Set an accessor object for the java.awt.AWTEvent class. 860 */ 861 public static void setAWTEventAccessor(AWTEventAccessor aea) { 862 awtEventAccessor = aea; 863 } 864 865 /* 866 * Retrieve the accessor object for the java.awt.AWTEvent class. 867 */ 868 public static AWTEventAccessor getAWTEventAccessor() { 869 if (awtEventAccessor == null) { 870 unsafe.ensureClassInitialized(AWTEvent.class); 871 } 872 return awtEventAccessor; 873 } 874 875 /* 876 * Set an accessor object for the java.awt.event.InputEvent class. 877 */ 878 public static void setInputEventAccessor(InputEventAccessor iea) { 879 inputEventAccessor = iea; 880 } 881 882 /* 883 * Retrieve the accessor object for the java.awt.event.InputEvent class. 884 */ 885 public static InputEventAccessor getInputEventAccessor() { 886 if (inputEventAccessor == null) { 887 unsafe.ensureClassInitialized(InputEvent.class); 888 } 889 return inputEventAccessor; 890 } 891 892 /* 893 * Set an accessor object for the java.awt.Frame class. 894 */ 895 public static void setFrameAccessor(FrameAccessor fa) { 896 frameAccessor = fa; 897 } 898 899 /* 900 * Retrieve the accessor object for the java.awt.Frame class. 901 */ 902 public static FrameAccessor getFrameAccessor() { 903 if (frameAccessor == null) { 904 unsafe.ensureClassInitialized(Frame.class); 905 } 906 return frameAccessor; 907 } 908 909 /* 910 * Set an accessor object for the java.awt.KeyboardFocusManager class. 911 */ 912 public static void setKeyboardFocusManagerAccessor(KeyboardFocusManagerAccessor kfma) { 913 kfmAccessor = kfma; 914 } 915 916 /* 917 * Retrieve the accessor object for the java.awt.KeyboardFocusManager class. 918 */ 919 public static KeyboardFocusManagerAccessor getKeyboardFocusManagerAccessor() { 920 if (kfmAccessor == null) { 921 unsafe.ensureClassInitialized(KeyboardFocusManager.class); 922 } 923 return kfmAccessor; 924 } 925 926 /* 927 * Set an accessor object for the java.awt.MenuComponent class. 928 */ 929 public static void setMenuComponentAccessor(MenuComponentAccessor mca) { 930 menuComponentAccessor = mca; 931 } 932 933 /* 934 * Retrieve the accessor object for the java.awt.MenuComponent class. 935 */ 936 public static MenuComponentAccessor getMenuComponentAccessor() { 937 if (menuComponentAccessor == null) { 938 unsafe.ensureClassInitialized(MenuComponent.class); 939 } 940 return menuComponentAccessor; 941 } 942 943 /* 944 * Set an accessor object for the java.awt.EventQueue class. 945 */ 946 public static void setEventQueueAccessor(EventQueueAccessor eqa) { 947 eventQueueAccessor = eqa; 948 } 949 950 /* 951 * Retrieve the accessor object for the java.awt.EventQueue class. 952 */ 953 public static EventQueueAccessor getEventQueueAccessor() { 954 if (eventQueueAccessor == null) { 955 unsafe.ensureClassInitialized(EventQueue.class); 956 } 957 return eventQueueAccessor; 958 } 959 960 /* 961 * Set an accessor object for the java.awt.PopupMenu class. 962 */ 963 public static void setPopupMenuAccessor(PopupMenuAccessor pma) { 964 popupMenuAccessor = pma; 965 } 966 967 /* 968 * Retrieve the accessor object for the java.awt.PopupMenu class. 969 */ 970 public static PopupMenuAccessor getPopupMenuAccessor() { 971 if (popupMenuAccessor == null) { 972 unsafe.ensureClassInitialized(PopupMenu.class); 973 } 974 return popupMenuAccessor; 975 } 976 977 /* 978 * Set an accessor object for the java.awt.FileDialog class. 979 */ 980 public static void setFileDialogAccessor(FileDialogAccessor fda) { 981 fileDialogAccessor = fda; 982 } 983 984 /* 985 * Retrieve the accessor object for the java.awt.FileDialog class. 986 */ 987 public static FileDialogAccessor getFileDialogAccessor() { 988 if (fileDialogAccessor == null) { 989 unsafe.ensureClassInitialized(FileDialog.class); 990 } 991 return fileDialogAccessor; 992 } 993 994 /* 995 * Set an accessor object for the java.awt.ScrollPaneAdjustable class. 996 */ 997 public static void setScrollPaneAdjustableAccessor(ScrollPaneAdjustableAccessor adj) { 998 scrollPaneAdjustableAccessor = adj; 999 } 1000 1001 /* 1002 * Retrieve the accessor object for the java.awt.ScrollPaneAdjustable 1003 * class. 1004 */ 1005 public static ScrollPaneAdjustableAccessor getScrollPaneAdjustableAccessor() { 1006 if (scrollPaneAdjustableAccessor == null) { 1007 unsafe.ensureClassInitialized(ScrollPaneAdjustable.class); 1008 } 1009 return scrollPaneAdjustableAccessor; 1010 } 1011 1012 /** 1013 * Set an accessor object for the java.awt.CheckboxMenuItem class. 1014 */ 1015 public static void setCheckboxMenuItemAccessor(CheckboxMenuItemAccessor cmia) { 1016 checkboxMenuItemAccessor = cmia; 1017 } 1018 1019 /** 1020 * Retrieve the accessor object for the java.awt.CheckboxMenuItem class. 1021 */ 1022 public static CheckboxMenuItemAccessor getCheckboxMenuItemAccessor() { 1023 if (checkboxMenuItemAccessor == null) { 1024 unsafe.ensureClassInitialized(CheckboxMenuItemAccessor.class); 1025 } 1026 return checkboxMenuItemAccessor; 1027 } 1028 1029 /** 1030 * Set an accessor object for the java.awt.Cursor class. 1031 */ 1032 public static void setCursorAccessor(CursorAccessor ca) { 1033 cursorAccessor = ca; 1034 } 1035 1036 /** 1037 * Retrieve the accessor object for the java.awt.Cursor class. 1038 */ 1039 public static CursorAccessor getCursorAccessor() { 1040 if (cursorAccessor == null) { 1041 unsafe.ensureClassInitialized(CursorAccessor.class); 1042 } 1043 return cursorAccessor; 1044 } 1045 1046 /** 1047 * Set an accessor object for the java.awt.MenuBar class. 1048 */ 1049 public static void setMenuBarAccessor(MenuBarAccessor mba) { 1050 menuBarAccessor = mba; 1051 } 1052 1053 /** 1054 * Retrieve the accessor object for the java.awt.MenuBar class. 1055 */ 1056 public static MenuBarAccessor getMenuBarAccessor() { 1057 if (menuBarAccessor == null) { 1058 unsafe.ensureClassInitialized(MenuBarAccessor.class); 1059 } 1060 return menuBarAccessor; 1061 } 1062 1063 /** 1064 * Set an accessor object for the java.awt.MenuItem class. 1065 */ 1066 public static void setMenuItemAccessor(MenuItemAccessor mia) { 1067 menuItemAccessor = mia; 1068 } 1069 1070 /** 1071 * Retrieve the accessor object for the java.awt.MenuItem class. 1072 */ 1073 public static MenuItemAccessor getMenuItemAccessor() { 1074 if (menuItemAccessor == null) { 1075 unsafe.ensureClassInitialized(MenuItemAccessor.class); 1076 } 1077 return menuItemAccessor; 1078 } 1079 1080 /** 1081 * Set an accessor object for the java.awt.Menu class. 1082 */ 1083 public static void setMenuAccessor(MenuAccessor ma) { 1084 menuAccessor = ma; 1085 } 1086 1087 /** 1088 * Retrieve the accessor object for the java.awt.Menu class. 1089 */ 1090 public static MenuAccessor getMenuAccessor() { 1091 if (menuAccessor == null) { 1092 unsafe.ensureClassInitialized(MenuAccessor.class); 1093 } 1094 return menuAccessor; 1095 } 1096 1097 /** 1098 * Set an accessor object for the java.awt.event.KeyEvent class. 1099 */ 1100 public static void setKeyEventAccessor(KeyEventAccessor kea) { 1101 keyEventAccessor = kea; 1102 } 1103 1104 /** 1105 * Retrieve the accessor object for the java.awt.event.KeyEvent class. 1106 */ 1107 public static KeyEventAccessor getKeyEventAccessor() { 1108 if (keyEventAccessor == null) { 1109 unsafe.ensureClassInitialized(KeyEventAccessor.class); 1110 } 1111 return keyEventAccessor; 1112 } 1113 1114 /** 1115 * Set an accessor object for the javax.swing.ClientPropertyKey class. 1116 */ 1117 public static void setClientPropertyKeyAccessor(ClientPropertyKeyAccessor cpka) { 1118 clientPropertyKeyAccessor = cpka; 1119 } 1120 1121 /** 1122 * Retrieve the accessor object for the javax.swing.ClientPropertyKey class. 1123 */ 1124 public static ClientPropertyKeyAccessor getClientPropertyKeyAccessor() { 1125 if (clientPropertyKeyAccessor == null) { 1126 unsafe.ensureClassInitialized(ClientPropertyKeyAccessor.class); 1127 } 1128 return clientPropertyKeyAccessor; 1129 } 1130 1131 /** 1132 * Set an accessor object for the java.awt.SystemTray class. 1133 */ 1134 public static void setSystemTrayAccessor(SystemTrayAccessor sta) { 1135 systemTrayAccessor = sta; 1136 } 1137 1138 /** 1139 * Retrieve the accessor object for the java.awt.SystemTray class. 1140 */ 1141 public static SystemTrayAccessor getSystemTrayAccessor() { 1142 if (systemTrayAccessor == null) { 1143 unsafe.ensureClassInitialized(SystemTrayAccessor.class); 1144 } 1145 return systemTrayAccessor; 1146 } 1147 1148 /** 1149 * Set an accessor object for the java.awt.TrayIcon class. 1150 */ 1151 public static void setTrayIconAccessor(TrayIconAccessor tia) { 1152 trayIconAccessor = tia; 1153 } 1154 1155 /** 1156 * Retrieve the accessor object for the java.awt.TrayIcon class. 1157 */ 1158 public static TrayIconAccessor getTrayIconAccessor() { 1159 if (trayIconAccessor == null) { 1160 unsafe.ensureClassInitialized(TrayIconAccessor.class); 1161 } 1162 return trayIconAccessor; 1163 } 1164 1165 /** 1166 * Set an accessor object for the java.awt.DefaultKeyboardFocusManager class. 1167 */ 1168 public static void setDefaultKeyboardFocusManagerAccessor(DefaultKeyboardFocusManagerAccessor dkfma) { 1169 defaultKeyboardFocusManagerAccessor = dkfma; 1170 } 1171 1172 /** 1173 * Retrieve the accessor object for the java.awt.DefaultKeyboardFocusManager class. 1174 */ 1175 public static DefaultKeyboardFocusManagerAccessor getDefaultKeyboardFocusManagerAccessor() { 1176 if (defaultKeyboardFocusManagerAccessor == null) { 1177 unsafe.ensureClassInitialized(DefaultKeyboardFocusManagerAccessor.class); 1178 } 1179 return defaultKeyboardFocusManagerAccessor; 1180 } 1181 /* 1182 * Set an accessor object for the java.awt.SequencedEvent class. 1183 */ 1184 public static void setSequencedEventAccessor(SequencedEventAccessor sea) { 1185 sequencedEventAccessor = sea; 1186 } 1187 1188 /* 1189 * Get the accessor object for the java.awt.SequencedEvent class. 1190 */ 1191 public static SequencedEventAccessor getSequencedEventAccessor() { 1192 // The class is not public. So we can't ensure it's initialized. 1193 // Null returned value means it's not initialized 1194 // (so not a single instance of the event has been created). 1195 return sequencedEventAccessor; 1196 } 1197 1198 /* 1199 * Set an accessor object for the java.awt.Toolkit class. 1200 */ 1201 public static void setToolkitAccessor(ToolkitAccessor ta) { 1202 toolkitAccessor = ta; 1203 } 1204 1205 /* 1206 * Get the accessor object for the java.awt.Toolkit class. 1207 */ 1208 public static ToolkitAccessor getToolkitAccessor() { 1209 if (toolkitAccessor == null) { 1210 unsafe.ensureClassInitialized(Toolkit.class); 1211 } 1212 1213 return toolkitAccessor; 1214 } 1215 1216 /* 1217 * Get the accessor object for the java.awt.event.InvocationEvent class. 1218 */ 1219 public static void setInvocationEventAccessor(InvocationEventAccessor invocationEventAccessor) { 1220 AWTAccessor.invocationEventAccessor = invocationEventAccessor; 1221 } 1222 1223 /* 1224 * Set the accessor object for the java.awt.event.InvocationEvent class. 1225 */ 1226 public static InvocationEventAccessor getInvocationEventAccessor() { 1227 return invocationEventAccessor; 1228 } 1229 1230 /* 1231 * Get the accessor object for the java.awt.SystemColor class. 1232 */ 1233 public static SystemColorAccessor getSystemColorAccessor() { 1234 if (systemColorAccessor == null) { 1235 unsafe.ensureClassInitialized(SystemColor.class); 1236 } 1237 1238 return systemColorAccessor; 1239 } 1240 1241 /* 1242 * Set the accessor object for the java.awt.SystemColor class. 1243 */ 1244 public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) { 1245 AWTAccessor.systemColorAccessor = systemColorAccessor; 1246 } 1247 1248 /* 1249 * Get the accessor object for the javax.accessibility.AccessibleContext class. 1250 */ 1251 public static AccessibleContextAccessor getAccessibleContextAccessor() { 1252 if (accessibleContextAccessor == null) { 1253 unsafe.ensureClassInitialized(AccessibleContext.class); 1254 } 1255 return accessibleContextAccessor; 1256 } 1257 1258 /* 1259 * Set the accessor object for the javax.accessibility.AccessibleContext class. 1260 */ 1261 public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) { 1262 AWTAccessor.accessibleContextAccessor = accessor; 1263 } 1264 }