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