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