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