1 /* 2 * Copyright (c) 2002, 2015, 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 com.sun.java.accessibility.util; 27 28 import java.util.*; 29 import java.awt.*; 30 import java.awt.event.*; 31 import javax.accessibility.*; 32 import javax.swing.*; 33 import javax.swing.event.*; 34 import sun.security.util.SecurityConstants.AWT; 35 36 /** 37 * <P>The {@code AWTEventMonitor} implements a suite of listeners that are 38 * conditionally installed on every AWT component instance in the Java 39 * Virtual Machine. The events captured by these listeners are made 40 * available through a unified set of listeners supported by {@code AWTEventMonitor}. 41 * With this, all the individual events on each of the AWT component 42 * instances are funneled into one set of listeners broken down by category 43 * (see {@link EventID} for the categories). 44 * <p>This class depends upon {@link EventQueueMonitor}, which provides the base 45 * level support for capturing the top-level containers as they are created. 46 */ 47 48 @jdk.Exported 49 public class AWTEventMonitor { 50 51 static private boolean runningOnJDK1_4 = false; 52 53 /** 54 * The current component with keyboard focus. 55 * 56 * @see #getComponentWithFocus 57 * 58 * @deprecated This field is unused; to get the component with focus use the 59 * getComponentWithFocus method. 60 */ 61 @Deprecated 62 static protected Component componentWithFocus = null; 63 64 static private Component componentWithFocus_private = null; 65 66 // Low-level listeners 67 /** 68 * The current list of registered ComponentListener classes. 69 * 70 * @see #addComponentListener 71 * @see #removeComponentListener 72 * 73 * @deprecated This field is unused. 74 */ 75 @Deprecated 76 static protected ComponentListener componentListener = null; 77 78 static private ComponentListener componentListener_private = null; 79 80 /** 81 * The current list of registered ContainerListener classes. 82 * 83 * @see #addContainerListener 84 * @see #removeContainerListener 85 * 86 * @deprecated This field is unused. 87 */ 88 @Deprecated 89 static protected ContainerListener containerListener = null; 90 91 static private ContainerListener containerListener_private = null; 92 93 /** 94 * The current list of registered FocusListener classes. 95 * 96 * @see #addFocusListener 97 * @see #removeFocusListener 98 * 99 * @deprecated This field is unused. 100 */ 101 @Deprecated 102 static protected FocusListener focusListener = null; 103 104 static private FocusListener focusListener_private = null; 105 106 /** 107 * The current list of registered KeyListener classes. 108 * 109 * @see #addKeyListener 110 * @see #removeKeyListener 111 * 112 * @deprecated This field is unused. 113 */ 114 @Deprecated 115 static protected KeyListener keyListener = null; 116 117 static private KeyListener keyListener_private = null; 118 119 /** 120 * The current list of registered MouseListener classes. 121 * 122 * @see #addMouseListener 123 * @see #removeMouseListener 124 * 125 * @deprecated This field is unused. 126 */ 127 @Deprecated 128 static protected MouseListener mouseListener = null; 129 130 static private MouseListener mouseListener_private = null; 131 132 /** 133 * The current list of registered MouseMotionListener classes. 134 * 135 * @see #addMouseMotionListener 136 * @see #removeMouseMotionListener 137 * 138 * @deprecated This field is unused. 139 */ 140 @Deprecated 141 static protected MouseMotionListener mouseMotionListener = null; 142 143 static private MouseMotionListener mouseMotionListener_private = null; 144 145 /** 146 * The current list of registered WindowListener classes. 147 * 148 * @see #addWindowListener 149 * @see #removeWindowListener 150 * 151 * @deprecated This field is unused. 152 */ 153 @Deprecated 154 static protected WindowListener windowListener = null; 155 156 static private WindowListener windowListener_private = null; 157 158 159 // Semantic listeners 160 /** 161 * The current list of registered ActionListener classes. 162 * 163 * @see #addActionListener 164 * @see #removeActionListener 165 * 166 * @deprecated This field is unused. 167 */ 168 @Deprecated 169 static protected ActionListener actionListener = null; 170 171 static private ActionListener actionListener_private = null; 172 173 /** 174 * The current list of registered AdjustmentListener classes. 175 * 176 * @see #addAdjustmentListener 177 * @see #removeAdjustmentListener 178 * 179 * @deprecated This field is unused. 180 */ 181 @Deprecated 182 static protected AdjustmentListener adjustmentListener = null; 183 184 static private AdjustmentListener adjustmentListener_private = null; 185 186 /** 187 * The current list of registered ItemListener classes. 188 * 189 * @see #addItemListener 190 * @see #removeItemListener 191 * 192 * @deprecated This field is unused. 193 */ 194 @Deprecated 195 static protected ItemListener itemListener = null; 196 197 static private ItemListener itemListener_private = null; 198 199 /** 200 * The current list of registered TextListener classes. 201 * 202 * @see #addTextListener 203 * @see #removeTextListener 204 * 205 * @deprecated This field is unused. 206 */ 207 @Deprecated 208 static protected TextListener textListener = null; 209 210 static private TextListener textListener_private = null; 211 212 213 /** 214 * The actual listener that is installed on the component instances. 215 * This listener calls the other registered listeners when an event 216 * occurs. By doing things this way, the actual number of listeners 217 * installed on a component instance is drastically reduced. 218 * 219 * @deprecated This field is unused. 220 */ 221 @Deprecated 222 static protected AWTEventsListener awtListener = new AWTEventsListener(); 223 224 static private final AWTEventsListener awtListener_private = new AWTEventsListener(); 225 226 /** 227 * Returns the component that currently has keyboard focus. The return 228 * value can be null. 229 * 230 * @return the component that has keyboard focus 231 */ 232 static public Component getComponentWithFocus() { 233 return componentWithFocus_private; 234 } 235 236 /* 237 * Check permissions 238 */ 239 static private void checkInstallPermission() { 240 SecurityManager security = System.getSecurityManager(); 241 if (security != null) { 242 security.checkPermission(AWT.ALL_AWT_EVENTS_PERMISSION); 243 } 244 } 245 246 /** 247 * Adds the specified listener to receive all {@link EventID#COMPONENT COMPONENT} 248 * events on each component instance in the Java Virtual Machine as they occur. 249 * <P>Note: this listener is automatically added to all component 250 * instances created after this method is called. In addition, it 251 * is only added to component instances that support this listener type. 252 * 253 * @param l the listener to add 254 * @see #removeComponentListener 255 */ 256 static public void addComponentListener(ComponentListener l) { 257 if (componentListener_private == null) { 258 checkInstallPermission(); 259 awtListener_private.installListeners(EventID.COMPONENT); 260 } 261 componentListener_private = AWTEventMulticaster.add(componentListener_private, l); 262 } 263 264 /** 265 * Removes the specified listener so it no longer receives 266 * {@link EventID#COMPONENT COMPONENT} events when they occur. 267 * 268 * @param l the listener to remove 269 * @see #addComponentListener 270 */ 271 static public void removeComponentListener(ComponentListener l) { 272 componentListener_private = AWTEventMulticaster.remove(componentListener_private, l); 273 if (componentListener_private == null) { 274 awtListener_private.removeListeners(EventID.COMPONENT); 275 } 276 } 277 278 /** 279 * Adds the specified listener to receive all {@link EventID#CONTAINER CONTAINER} 280 * events on each component instance in the Java Virtual Machine as they occur. 281 * <P>Note: this listener is automatically added to all component 282 * instances created after this method is called. In addition, it 283 * is only added to component instances that support this listener type. 284 * 285 * @param l the listener to add 286 * @see #removeContainerListener 287 */ 288 static public void addContainerListener(ContainerListener l) { 289 containerListener_private = AWTEventMulticaster.add(containerListener_private, l); 290 } 291 292 /** 293 * Removes the specified listener so it no longer receives 294 * {@link EventID#CONTAINER CONTAINER} events when they occur. 295 * 296 * @param l the listener to remove 297 * @see #addContainerListener 298 */ 299 static public void removeContainerListener(ContainerListener l) { 300 containerListener_private = AWTEventMulticaster.remove(containerListener_private, l); 301 } 302 303 /** 304 * Adds the specified listener to receive all {@link EventID#FOCUS FOCUS} events 305 * on each component instance in the Java Virtual Machine when they occur. 306 * <P>Note: this listener is automatically added to all component 307 * instances created after this method is called. In addition, it 308 * is only added to component instances that support this listener type. 309 * 310 * @param l the listener to add 311 * @see #removeFocusListener 312 */ 313 static public void addFocusListener(FocusListener l) { 314 focusListener_private = AWTEventMulticaster.add(focusListener_private, l); 315 } 316 317 /** 318 * Removes the specified listener so it no longer receives {@link EventID#FOCUS FOCUS} 319 * events when they occur. 320 * 321 * @param l the listener to remove 322 * @see #addFocusListener 323 */ 324 static public void removeFocusListener(FocusListener l) { 325 focusListener_private = AWTEventMulticaster.remove(focusListener_private, l); 326 } 327 328 /** 329 * Adds the specified listener to receive all {@link EventID#KEY KEY} events on each 330 * component instance in the Java Virtual Machine when they occur. 331 * <P>Note: this listener is automatically added to all component 332 * instances created after this method is called. In addition, it 333 * is only added to component instances that support this listener type. 334 * 335 * @param l the listener to add 336 * @see #removeKeyListener 337 */ 338 static public void addKeyListener(KeyListener l) { 339 if (keyListener_private == null) { 340 checkInstallPermission(); 341 awtListener_private.installListeners(EventID.KEY); 342 } 343 keyListener_private = AWTEventMulticaster.add(keyListener_private, l); 344 } 345 346 /** 347 * Removes the specified listener so it no longer receives {@link EventID#KEY KEY} 348 * events when they occur. 349 * 350 * @param l the listener to remove 351 * @see #addKeyListener 352 */ 353 static public void removeKeyListener(KeyListener l) { 354 keyListener_private = AWTEventMulticaster.remove(keyListener_private, l); 355 if (keyListener_private == null) { 356 awtListener_private.removeListeners(EventID.KEY); 357 } 358 } 359 360 /** 361 * Adds the specified listener to receive all {@link EventID#MOUSE MOUSE} events 362 * on each component instance in the Java Virtual Machine when they occur. 363 * <P>Note: this listener is automatically added to all component 364 * instances created after this method is called. In addition, it 365 * is only added to component instances that support this listener type. 366 * 367 * @param l the listener to add 368 * @see #removeMouseListener 369 */ 370 static public void addMouseListener(MouseListener l) { 371 if (mouseListener_private == null) { 372 checkInstallPermission(); 373 awtListener_private.installListeners(EventID.MOUSE); 374 } 375 mouseListener_private = AWTEventMulticaster.add(mouseListener_private, l); 376 } 377 378 /** 379 * Removes the specified listener so it no longer receives 380 * {@link EventID#MOUSE MOUSE} events when they occur. 381 * 382 * @param l the listener to remove 383 * @see #addMouseListener 384 */ 385 static public void removeMouseListener(MouseListener l) { 386 mouseListener_private = AWTEventMulticaster.remove(mouseListener_private, l); 387 if (mouseListener_private == null) { 388 awtListener_private.removeListeners(EventID.MOUSE); 389 } 390 } 391 392 /** 393 * Adds the specified listener to receive all mouse {@link EventID#MOTION MOTION} 394 * events on each component instance in the Java Virtual Machine when they occur. 395 * <P>Note: this listener is automatically added to all component 396 * instances created after this method is called. In addition, it 397 * is only added to component instances that support this listener type. 398 * 399 * @param l the listener to add 400 * @see #removeMouseMotionListener 401 */ 402 static public void addMouseMotionListener(MouseMotionListener l) { 403 if (mouseMotionListener_private == null) { 404 checkInstallPermission(); 405 awtListener_private.installListeners(EventID.MOTION); 406 } 407 mouseMotionListener_private = AWTEventMulticaster.add(mouseMotionListener_private, l); 408 } 409 410 /** 411 * Removes the specified listener so it no longer receives 412 * {@link EventID#MOTION MOTION} events when they occur. 413 * 414 * @param l the listener to remove 415 * @see #addMouseMotionListener 416 */ 417 static public void removeMouseMotionListener(MouseMotionListener l) { 418 mouseMotionListener_private = AWTEventMulticaster.remove(mouseMotionListener_private, l); 419 if (mouseMotionListener_private == null) { 420 awtListener_private.removeListeners(EventID.MOTION); 421 } 422 } 423 424 /** 425 * Adds the specified listener to receive all {@link EventID#WINDOW WINDOW} 426 * events on each component instance in the Java Virtual Machine when they occur. 427 * <P>Note: this listener is automatically added to all component 428 * instances created after this method is called. In addition, it 429 * is only added to component instances that support this listener type. 430 * 431 * @param l the listener to add 432 * @see #removeWindowListener 433 */ 434 static public void addWindowListener(WindowListener l) { 435 if (windowListener_private == null) { 436 checkInstallPermission(); 437 awtListener_private.installListeners(EventID.WINDOW); 438 } 439 windowListener_private = AWTEventMulticaster.add(windowListener_private, l); 440 } 441 442 /** 443 * Removes the specified listener so it no longer receives 444 * {@link EventID#WINDOW WINDOW} events when they occur. 445 * 446 * @param l the listener to remove 447 * @see #addWindowListener 448 */ 449 static public void removeWindowListener(WindowListener l) { 450 windowListener_private = AWTEventMulticaster.remove(windowListener_private, l); 451 if (windowListener_private == null) { 452 awtListener_private.removeListeners(EventID.WINDOW); 453 } 454 } 455 456 /** 457 * Adds the specified listener to receive all {@link EventID#ACTION ACTION} 458 * events on each component instance in the Java Virtual Machine when they occur. 459 * <P>Note: This listener is automatically added to all component 460 * instances created after this method is called. In addition, it 461 * is only added to component instances that support this listener type. 462 * 463 * @param l the listener to add 464 * @see #removeActionListener 465 */ 466 static public void addActionListener(ActionListener l) { 467 if (actionListener_private == null) { 468 checkInstallPermission(); 469 awtListener_private.installListeners(EventID.ACTION); 470 } 471 actionListener_private = AWTEventMulticaster.add(actionListener_private, l); 472 } 473 474 /** 475 * Removes the specified listener so it no longer receives 476 * {@link EventID#ACTION ACTION} events when they occur. 477 * 478 * @param l the listener to remove 479 * @see #addActionListener 480 */ 481 static public void removeActionListener(ActionListener l) { 482 actionListener_private = AWTEventMulticaster.remove(actionListener_private, l); 483 if (actionListener_private == null) { 484 awtListener_private.removeListeners(EventID.ACTION); 485 } 486 } 487 488 /** 489 * Adds the specified listener to receive all 490 * {@link EventID#ADJUSTMENT ADJUSTMENT} events on each component instance 491 * in the Java Virtual Machine when they occur. 492 * <P>Note: this listener is automatically added to all component 493 * instances created after this method is called. In addition, it 494 * is only added to component instances that support this listener type. 495 * 496 * @param l the listener to add 497 * @see #removeAdjustmentListener 498 */ 499 static public void addAdjustmentListener(AdjustmentListener l) { 500 if (adjustmentListener_private == null) { 501 checkInstallPermission(); 502 awtListener_private.installListeners(EventID.ADJUSTMENT); 503 } 504 adjustmentListener_private = AWTEventMulticaster.add(adjustmentListener_private, l); 505 } 506 507 /** 508 * Removes the specified listener so it no longer receives 509 * {@link EventID#ADJUSTMENT ADJUSTMENT} events when they occur. 510 * 511 * @param l the listener to remove 512 * @see #addAdjustmentListener 513 */ 514 static public void removeAdjustmentListener(AdjustmentListener l) { 515 adjustmentListener_private = AWTEventMulticaster.remove(adjustmentListener_private, l); 516 if (adjustmentListener_private == null) { 517 awtListener_private.removeListeners(EventID.ADJUSTMENT); 518 } 519 } 520 521 /** 522 * Adds the specified listener to receive all {@link EventID#ITEM ITEM} events 523 * on each component instance in the Java Virtual Machine when they occur. 524 * <P>Note: this listener is automatically added to all component 525 * instances created after this method is called. In addition, it 526 * is only added to component instances that support this listener type. 527 * 528 * @param l the listener to add 529 * @see #removeItemListener 530 */ 531 static public void addItemListener(ItemListener l) { 532 if (itemListener_private == null) { 533 checkInstallPermission(); 534 awtListener_private.installListeners(EventID.ITEM); 535 } 536 itemListener_private = AWTEventMulticaster.add(itemListener_private, l); 537 } 538 539 /** 540 * Removes the specified listener so it no longer receives {@link EventID#ITEM ITEM} 541 * events when they occur. 542 * 543 * @param l the listener to remove 544 * @see #addItemListener 545 */ 546 static public void removeItemListener(ItemListener l) { 547 itemListener_private = AWTEventMulticaster.remove(itemListener_private, l); 548 if (itemListener_private == null) { 549 awtListener_private.removeListeners(EventID.ITEM); 550 } 551 } 552 553 /** 554 * Adds the specified listener to receive all {@link EventID#TEXT TEXT} events 555 * on each component instance in the Java Virtual Machine when they occur. 556 * <P>Note: this listener is automatically added to all component 557 * instances created after this method is called. In addition, it 558 * is only added to component instances that support this listener type. 559 * 560 * @param l the listener to add 561 * @see #removeTextListener 562 */ 563 static public void addTextListener(TextListener l) { 564 if (textListener_private == null) { 565 checkInstallPermission(); 566 awtListener_private.installListeners(EventID.TEXT); 567 } 568 textListener_private = AWTEventMulticaster.add(textListener_private, l); 569 } 570 571 /** 572 * Removes the specified listener so it no longer receives {@link EventID#TEXT TEXT} 573 * events when they occur. 574 * 575 * @param l the listener to remove 576 * @see #addTextListener 577 */ 578 static public void removeTextListener(TextListener l) { 579 textListener_private = AWTEventMulticaster.remove(textListener_private, l); 580 if (textListener_private == null) { 581 awtListener_private.removeListeners(EventID.TEXT); 582 } 583 } 584 585 586 /** 587 * AWTEventsListener is the class that does all the work for AWTEventMonitor. 588 * It is not intended for use by any other class except AWTEventMonitor. 589 * 590 */ 591 592 static class AWTEventsListener implements TopLevelWindowListener, 593 ActionListener, AdjustmentListener, ComponentListener, 594 ContainerListener, FocusListener, ItemListener, KeyListener, 595 MouseListener, MouseMotionListener, TextListener, WindowListener, 596 ChangeListener { 597 598 /** 599 * internal variables for Action introspection 600 */ 601 private java.lang.Class actionListeners[]; 602 private java.lang.reflect.Method removeActionMethod; 603 private java.lang.reflect.Method addActionMethod; 604 private java.lang.Object actionArgs[]; 605 606 /** 607 * internal variables for Item introspection 608 */ 609 private java.lang.Class itemListeners[]; 610 private java.lang.reflect.Method removeItemMethod; 611 private java.lang.reflect.Method addItemMethod; 612 private java.lang.Object itemArgs[]; 613 614 /** 615 * internal variables for Text introspection 616 */ 617 private java.lang.Class textListeners[]; 618 private java.lang.reflect.Method removeTextMethod; 619 private java.lang.reflect.Method addTextMethod; 620 private java.lang.Object textArgs[]; 621 622 /** 623 * internal variables for Window introspection 624 */ 625 private java.lang.Class windowListeners[]; 626 private java.lang.reflect.Method removeWindowMethod; 627 private java.lang.reflect.Method addWindowMethod; 628 private java.lang.Object windowArgs[]; 629 630 /** 631 * Create a new instance of this class and install it on each component 632 * instance in the virtual machine that supports any of the currently 633 * registered listeners in AWTEventMonitor. Also registers itself 634 * as a TopLevelWindowListener with EventQueueMonitor so it can 635 * automatically add new listeners to new components. 636 * 637 * @see EventQueueMonitor 638 * @see AWTEventMonitor 639 */ 640 public AWTEventsListener() { 641 String version = System.getProperty("java.version"); 642 if (version != null) { 643 runningOnJDK1_4 = (version.compareTo("1.4") >= 0); 644 } 645 initializeIntrospection(); 646 installListeners(); 647 if (runningOnJDK1_4) { 648 MenuSelectionManager.defaultManager().addChangeListener(this); 649 } 650 EventQueueMonitor.addTopLevelWindowListener(this); 651 } 652 653 /** 654 * Set up all of the variables needed for introspection 655 */ 656 private boolean initializeIntrospection() { 657 try { 658 actionListeners = new java.lang.Class[1]; 659 actionArgs = new java.lang.Object[1]; 660 actionListeners[0] = Class.forName("java.awt.event.ActionListener"); 661 actionArgs[0] = this; 662 663 itemListeners = new java.lang.Class[1]; 664 itemArgs = new java.lang.Object[1]; 665 itemListeners[0] = Class.forName("java.awt.event.ItemListener"); 666 itemArgs[0] = this; 667 668 textListeners = new java.lang.Class[1]; 669 textArgs = new java.lang.Object[1]; 670 textListeners[0] = Class.forName("java.awt.event.TextListener"); 671 textArgs[0] = this; 672 673 windowListeners = new java.lang.Class[1]; 674 windowArgs = new java.lang.Object[1]; 675 windowListeners[0] = Class.forName("java.awt.event.WindowListener"); 676 windowArgs[0] = this; 677 678 return true; 679 } catch (ClassNotFoundException e) { 680 System.out.println("EXCEPTION - Class 'java.awt.event.*' not in CLASSPATH"); 681 return false; 682 } 683 } 684 685 /** 686 * Installs all currently registered listeners on all components based 687 * upon the current topLevelWindows cached by EventQueueMonitor. 688 * @see EventQueueMonitor 689 * @see AWTEventMonitor 690 */ 691 protected void installListeners() { 692 Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); 693 if (topLevelWindows != null) { 694 for (int i = 0; i < topLevelWindows.length; i++) { 695 installListeners(topLevelWindows[i]); 696 } 697 } 698 } 699 700 /** 701 * Installs listeners for the given event ID on all components based 702 * upon the current topLevelWindows cached by EventQueueMonitor. 703 * @see EventID 704 * @param eventID the event ID 705 */ 706 protected void installListeners(int eventID) { 707 Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); 708 if (topLevelWindows != null) { 709 for (int i = 0; i < topLevelWindows.length; i++) { 710 installListeners(topLevelWindows[i], eventID); 711 } 712 } 713 } 714 715 /** 716 * Installs all currently registered listeners to just the component. 717 * @param c the component to add listeners to 718 */ 719 protected void installListeners(Component c) { 720 721 // Container and focus listeners are always installed for our own use. 722 // 723 installListeners(c,EventID.CONTAINER); 724 installListeners(c,EventID.FOCUS); 725 726 // conditionally install low-level listeners 727 // 728 if (AWTEventMonitor.componentListener_private != null) { 729 installListeners(c,EventID.COMPONENT); 730 } 731 if (AWTEventMonitor.keyListener_private != null) { 732 installListeners(c,EventID.KEY); 733 } 734 if (AWTEventMonitor.mouseListener_private != null) { 735 installListeners(c,EventID.MOUSE); 736 } 737 if (AWTEventMonitor.mouseMotionListener_private != null) { 738 installListeners(c,EventID.MOTION); 739 } 740 if (AWTEventMonitor.windowListener_private != null) { 741 installListeners(c,EventID.WINDOW); 742 } 743 744 // conditionally install Semantic listeners 745 // 746 if (AWTEventMonitor.actionListener_private != null) { 747 installListeners(c,EventID.ACTION); 748 } 749 if (AWTEventMonitor.adjustmentListener_private != null) { 750 installListeners(c,EventID.ADJUSTMENT); 751 } 752 if (AWTEventMonitor.itemListener_private != null) { 753 installListeners(c,EventID.ITEM); 754 } 755 if (AWTEventMonitor.textListener_private != null) { 756 installListeners(c,EventID.TEXT); 757 } 758 } 759 760 public void stateChanged(ChangeEvent e) { 761 processFocusGained(); 762 } 763 764 private void processFocusGained() { 765 Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); 766 if (focusOwner == null) { 767 return; 768 } 769 MenuSelectionManager.defaultManager().removeChangeListener(this); 770 MenuSelectionManager.defaultManager().addChangeListener(this); 771 772 // Only menus and popup selections are handled by the JRootPane. 773 if (focusOwner instanceof JRootPane) { 774 MenuElement [] path = 775 MenuSelectionManager.defaultManager().getSelectedPath(); 776 if (path.length > 1) { 777 Component penult = path[path.length-2].getComponent(); 778 Component last = path[path.length-1].getComponent(); 779 780 if (last instanceof JPopupMenu || 781 last instanceof JMenu) { 782 // This is a popup with nothing in the popup 783 // selected. The menu itself is selected. 784 componentWithFocus_private = last; 785 } else if (penult instanceof JPopupMenu) { 786 // This is a popup with an item selected 787 componentWithFocus_private = penult; 788 } 789 } 790 } else { 791 // The focus owner has the selection. 792 componentWithFocus_private = focusOwner; 793 } 794 } 795 796 /** 797 * Installs the given listener on the component and any of its children. 798 * As a precaution, it always attempts to remove itself as a listener 799 * first so it's always guaranteed to have installed itself just once. 800 * @param c the component to add listeners to 801 * @param eventID the eventID to add listeners for 802 * @see EventID 803 */ 804 protected void installListeners(Component c, int eventID) { 805 806 // install the appropriate listener hook into this component 807 // 808 switch (eventID) { 809 810 case EventID.ACTION: 811 try { 812 removeActionMethod = c.getClass().getMethod( 813 "removeActionListener", actionListeners); 814 addActionMethod = c.getClass().getMethod( 815 "addActionListener", actionListeners); 816 try { 817 removeActionMethod.invoke(c, actionArgs); 818 addActionMethod.invoke(c, actionArgs); 819 } catch (java.lang.reflect.InvocationTargetException e) { 820 System.out.println("Exception: " + e.toString()); 821 } catch (IllegalAccessException e) { 822 System.out.println("Exception: " + e.toString()); 823 } 824 } catch (NoSuchMethodException e) { 825 // System.out.println("Exception: " + e.toString()); 826 } catch (SecurityException e) { 827 System.out.println("Exception: " + e.toString()); 828 } 829 break; 830 831 case EventID.ADJUSTMENT: 832 if (c instanceof Adjustable) { 833 ((Adjustable) c).removeAdjustmentListener(this); 834 ((Adjustable) c).addAdjustmentListener(this); 835 } 836 break; 837 838 case EventID.COMPONENT: 839 c.removeComponentListener(this); 840 c.addComponentListener(this); 841 break; 842 843 case EventID.CONTAINER: 844 if (c instanceof Container) { 845 ((Container) c).removeContainerListener(this); 846 ((Container) c).addContainerListener(this); 847 } 848 break; 849 850 case EventID.FOCUS: 851 c.removeFocusListener(this); 852 c.addFocusListener(this); 853 854 if (runningOnJDK1_4) { 855 processFocusGained(); 856 857 } else { // not runningOnJDK1_4 858 if ((c != componentWithFocus_private) && c.hasFocus()) { 859 componentWithFocus_private = c; 860 } 861 } 862 break; 863 864 case EventID.ITEM: 865 try { 866 removeItemMethod = c.getClass().getMethod( 867 "removeItemListener", itemListeners); 868 addItemMethod = c.getClass().getMethod( 869 "addItemListener", itemListeners); 870 try { 871 removeItemMethod.invoke(c, itemArgs); 872 addItemMethod.invoke(c, itemArgs); 873 } catch (java.lang.reflect.InvocationTargetException e) { 874 System.out.println("Exception: " + e.toString()); 875 } catch (IllegalAccessException e) { 876 System.out.println("Exception: " + e.toString()); 877 } 878 } catch (NoSuchMethodException e) { 879 // System.out.println("Exception: " + e.toString()); 880 } catch (SecurityException e) { 881 System.out.println("Exception: " + e.toString()); 882 } 883 // [PK] CheckboxMenuItem isn't a component but it does 884 // implement Interface ItemSelectable!! 885 // if (c instanceof CheckboxMenuItem) { 886 // ((CheckboxMenuItem) c).removeItemListener(this); 887 // ((CheckboxMenuItem) c).addItemListener(this); 888 break; 889 890 case EventID.KEY: 891 c.removeKeyListener(this); 892 c.addKeyListener(this); 893 break; 894 895 case EventID.MOUSE: 896 c.removeMouseListener(this); 897 c.addMouseListener(this); 898 break; 899 900 case EventID.MOTION: 901 c.removeMouseMotionListener(this); 902 c.addMouseMotionListener(this); 903 break; 904 905 case EventID.TEXT: 906 try { 907 removeTextMethod = c.getClass().getMethod( 908 "removeTextListener", textListeners); 909 addTextMethod = c.getClass().getMethod( 910 "addTextListener", textListeners); 911 try { 912 removeTextMethod.invoke(c, textArgs); 913 addTextMethod.invoke(c, textArgs); 914 } catch (java.lang.reflect.InvocationTargetException e) { 915 System.out.println("Exception: " + e.toString()); 916 } catch (IllegalAccessException e) { 917 System.out.println("Exception: " + e.toString()); 918 } 919 } catch (NoSuchMethodException e) { 920 // System.out.println("Exception: " + e.toString()); 921 } catch (SecurityException e) { 922 System.out.println("Exception: " + e.toString()); 923 } 924 break; 925 926 case EventID.WINDOW: 927 try { 928 removeWindowMethod = c.getClass().getMethod( 929 "removeWindowListener", windowListeners); 930 addWindowMethod = c.getClass().getMethod( 931 "addWindowListener", windowListeners); 932 try { 933 removeWindowMethod.invoke(c, windowArgs); 934 addWindowMethod.invoke(c, windowArgs); 935 } catch (java.lang.reflect.InvocationTargetException e) { 936 System.out.println("Exception: " + e.toString()); 937 } catch (IllegalAccessException e) { 938 System.out.println("Exception: " + e.toString()); 939 } 940 } catch (NoSuchMethodException e) { 941 // System.out.println("Exception: " + e.toString()); 942 } catch (SecurityException e) { 943 System.out.println("Exception: " + e.toString()); 944 } 945 break; 946 947 // Don't bother recursing the children if this isn't going to 948 // accomplish anything. 949 // 950 default: 951 return; 952 } 953 954 // if this component is a container, recurse through children 955 // 956 if (c instanceof Container) { 957 int count = ((Container) c).getComponentCount(); 958 for (int i = 0; i < count; i++) { 959 installListeners(((Container) c).getComponent(i), eventID); 960 } 961 } 962 } 963 964 /** 965 * Removes all listeners for the given event ID on all components based 966 * upon the topLevelWindows cached by EventQueueMonitor. 967 * @param eventID the event ID 968 * @see EventID 969 */ 970 protected void removeListeners(int eventID) { 971 Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); 972 if (topLevelWindows != null) { 973 for (int i = 0; i < topLevelWindows.length; i++) { 974 removeListeners(topLevelWindows[i], eventID); 975 } 976 } 977 } 978 979 /** 980 * Removes all listeners for the given component and all its children. 981 * @param c the component 982 */ 983 protected void removeListeners(Component c) { 984 985 // conditionally remove low-level listeners 986 // 987 if (AWTEventMonitor.componentListener_private != null) { 988 removeListeners(c,EventID.COMPONENT); 989 } 990 if (AWTEventMonitor.keyListener_private != null) { 991 removeListeners(c,EventID.KEY); 992 } 993 if (AWTEventMonitor.mouseListener_private != null) { 994 removeListeners(c,EventID.MOUSE); 995 } 996 if (AWTEventMonitor.mouseMotionListener_private != null) { 997 removeListeners(c,EventID.MOTION); 998 } 999 if (AWTEventMonitor.windowListener_private != null) { 1000 removeListeners(c,EventID.WINDOW); 1001 } 1002 1003 // Remove semantic listeners 1004 // 1005 if (AWTEventMonitor.actionListener_private != null) { 1006 removeListeners(c,EventID.ACTION); 1007 } 1008 if (AWTEventMonitor.adjustmentListener_private != null) { 1009 removeListeners(c,EventID.ADJUSTMENT); 1010 } 1011 if (AWTEventMonitor.itemListener_private != null) { 1012 removeListeners(c,EventID.ITEM); 1013 } 1014 if (AWTEventMonitor.textListener_private != null) { 1015 removeListeners(c,EventID.TEXT); 1016 } 1017 } 1018 1019 /** 1020 * Removes all listeners for the event ID from the component and all 1021 * of its children. 1022 * @param c the component to remove listeners from 1023 * @see EventID 1024 */ 1025 protected void removeListeners(Component c, int eventID) { 1026 1027 // remove the appropriate listener hook into this component 1028 // 1029 switch (eventID) { 1030 1031 case EventID.ACTION: 1032 try { 1033 removeActionMethod = c.getClass().getMethod( 1034 "removeActionListener", 1035 actionListeners); 1036 try { 1037 removeActionMethod.invoke(c, actionArgs); 1038 } catch (java.lang.reflect.InvocationTargetException e) { 1039 System.out.println("Exception: " + e.toString()); 1040 } catch (IllegalAccessException e) { 1041 System.out.println("Exception: " + e.toString()); 1042 } 1043 } catch (NoSuchMethodException e) { 1044 // System.out.println("Exception: " + e.toString()); 1045 } catch (SecurityException e) { 1046 System.out.println("Exception: " + e.toString()); 1047 } 1048 break; 1049 1050 case EventID.ADJUSTMENT: 1051 if (c instanceof Adjustable) { 1052 ((Adjustable) c).removeAdjustmentListener(this); 1053 } 1054 break; 1055 1056 case EventID.COMPONENT: 1057 c.removeComponentListener(this); 1058 break; 1059 1060 // Never remove these because we're always interested in them 1061 // for our own use. 1062 //case EventID.CONTAINER: 1063 // if (c instanceof Container) { 1064 // ((Container) c).removeContainerListener(this); 1065 // } 1066 // break; 1067 // 1068 //case EventID.FOCUS: 1069 // c.removeFocusListener(this); 1070 // break; 1071 1072 case EventID.ITEM: 1073 try { 1074 removeItemMethod = c.getClass().getMethod( 1075 "removeItemListener", itemListeners); 1076 try { 1077 removeItemMethod.invoke(c, itemArgs); 1078 } catch (java.lang.reflect.InvocationTargetException e) { 1079 System.out.println("Exception: " + e.toString()); 1080 } catch (IllegalAccessException e) { 1081 System.out.println("Exception: " + e.toString()); 1082 } 1083 } catch (NoSuchMethodException e) { 1084 // System.out.println("Exception: " + e.toString()); 1085 } catch (SecurityException e) { 1086 System.out.println("Exception: " + e.toString()); 1087 } 1088 // [PK] CheckboxMenuItem isn't a component but it does 1089 // implement Interface ItemSelectable!! 1090 // if (c instanceof CheckboxMenuItem) { 1091 // ((CheckboxMenuItem) c).removeItemListener(this); 1092 break; 1093 1094 case EventID.KEY: 1095 c.removeKeyListener(this); 1096 break; 1097 1098 case EventID.MOUSE: 1099 c.removeMouseListener(this); 1100 break; 1101 1102 case EventID.MOTION: 1103 c.removeMouseMotionListener(this); 1104 break; 1105 1106 case EventID.TEXT: 1107 try { 1108 removeTextMethod = c.getClass().getMethod( 1109 "removeTextListener", textListeners); 1110 try { 1111 removeTextMethod.invoke(c, textArgs); 1112 } catch (java.lang.reflect.InvocationTargetException e) { 1113 System.out.println("Exception: " + e.toString()); 1114 } catch (IllegalAccessException e) { 1115 System.out.println("Exception: " + e.toString()); 1116 } 1117 } catch (NoSuchMethodException e) { 1118 // System.out.println("Exception: " + e.toString()); 1119 } catch (SecurityException e) { 1120 System.out.println("Exception: " + e.toString()); 1121 } 1122 break; 1123 1124 case EventID.WINDOW: 1125 try { 1126 removeWindowMethod = c.getClass().getMethod( 1127 "removeWindowListener", windowListeners); 1128 try { 1129 removeWindowMethod.invoke(c, windowArgs); 1130 } catch (java.lang.reflect.InvocationTargetException e) { 1131 System.out.println("Exception: " + e.toString()); 1132 } catch (IllegalAccessException e) { 1133 System.out.println("Exception: " + e.toString()); 1134 } 1135 } catch (NoSuchMethodException e) { 1136 // System.out.println("Exception: " + e.toString()); 1137 } catch (SecurityException e) { 1138 System.out.println("Exception: " + e.toString()); 1139 } 1140 break; 1141 1142 default: 1143 return; 1144 } 1145 1146 if (c instanceof Container) { 1147 int count = ((Container) c).getComponentCount(); 1148 for (int i = 0; i < count; i++) { 1149 removeListeners(((Container) c).getComponent(i), eventID); 1150 } 1151 } 1152 } 1153 1154 /********************************************************************/ 1155 /* */ 1156 /* Listener Interface Methods */ 1157 /* */ 1158 /********************************************************************/ 1159 1160 /* TopLevelWindow Methods ***************************************/ 1161 1162 /** 1163 * Called when top level window is created. 1164 * @see EventQueueMonitor 1165 * @see EventQueueMonitor#addTopLevelWindowListener 1166 */ 1167 public void topLevelWindowCreated(Window w) { 1168 installListeners(w); 1169 } 1170 1171 /** 1172 * Called when top level window is destroyed. 1173 * @see EventQueueMonitor 1174 * @see EventQueueMonitor#addTopLevelWindowListener 1175 */ 1176 public void topLevelWindowDestroyed(Window w) { 1177 } 1178 1179 /* ActionListener Methods ***************************************/ 1180 1181 /** 1182 * Called when an action is performed. 1183 * @see AWTEventMonitor#addActionListener 1184 */ 1185 public void actionPerformed(ActionEvent e) { 1186 if (AWTEventMonitor.actionListener_private != null) { 1187 AWTEventMonitor.actionListener_private.actionPerformed(e); 1188 } 1189 } 1190 1191 /* AdjustmentListener Methods ***********************************/ 1192 1193 /** 1194 * Called when an adjustment is made. 1195 * @see AWTEventMonitor#addAdjustmentListener 1196 */ 1197 public void adjustmentValueChanged(AdjustmentEvent e) { 1198 if (AWTEventMonitor.adjustmentListener_private != null) { 1199 AWTEventMonitor.adjustmentListener_private.adjustmentValueChanged(e); 1200 } 1201 } 1202 1203 /* ComponentListener Methods ************************************/ 1204 1205 /** 1206 * Called when a component is hidden. 1207 * @see AWTEventMonitor#addComponentListener 1208 */ 1209 public void componentHidden(ComponentEvent e) { 1210 if (AWTEventMonitor.componentListener_private != null) { 1211 AWTEventMonitor.componentListener_private.componentHidden(e); 1212 } 1213 } 1214 1215 /** 1216 * Called when a component is moved. 1217 * @see AWTEventMonitor#addComponentListener 1218 */ 1219 public void componentMoved(ComponentEvent e) { 1220 if (AWTEventMonitor.componentListener_private != null) { 1221 AWTEventMonitor.componentListener_private.componentMoved(e); 1222 } 1223 } 1224 1225 /** 1226 * Called when a component is resized. 1227 * @see AWTEventMonitor#addComponentListener 1228 */ 1229 public void componentResized(ComponentEvent e) { 1230 if (AWTEventMonitor.componentListener_private != null) { 1231 AWTEventMonitor.componentListener_private.componentResized(e); 1232 } 1233 } 1234 1235 /** 1236 * Called when a component is shown. 1237 * @see AWTEventMonitor#addComponentListener 1238 */ 1239 public void componentShown(ComponentEvent e) { 1240 if (AWTEventMonitor.componentListener_private != null) { 1241 AWTEventMonitor.componentListener_private.componentShown(e); 1242 } 1243 } 1244 1245 /* ContainerListener Methods ************************************/ 1246 1247 /** 1248 * Called when a component is added to a container. 1249 * @see AWTEventMonitor#addContainerListener 1250 */ 1251 public void componentAdded(ContainerEvent e) { 1252 installListeners(e.getChild()); 1253 if (AWTEventMonitor.containerListener_private != null) { 1254 AWTEventMonitor.containerListener_private.componentAdded(e); 1255 } 1256 } 1257 1258 /** 1259 * Called when a component is removed from a container. 1260 * @see AWTEventMonitor#addContainerListener 1261 */ 1262 public void componentRemoved(ContainerEvent e) { 1263 removeListeners(e.getChild()); 1264 if (AWTEventMonitor.containerListener_private != null) { 1265 AWTEventMonitor.containerListener_private.componentRemoved(e); 1266 } 1267 } 1268 1269 /* FocusListener Methods ****************************************/ 1270 1271 /** 1272 * Called when a component gains keyboard focus. 1273 * @see AWTEventMonitor#addFocusListener 1274 */ 1275 public void focusGained(FocusEvent e) { 1276 AWTEventMonitor.componentWithFocus_private = (Component) e.getSource(); 1277 if (AWTEventMonitor.focusListener_private != null) { 1278 AWTEventMonitor.focusListener_private.focusGained(e); 1279 } 1280 } 1281 1282 /** 1283 * Called when a component loses keyboard focus. 1284 * @see AWTEventMonitor#addFocusListener 1285 */ 1286 public void focusLost(FocusEvent e) { 1287 AWTEventMonitor.componentWithFocus_private = null; 1288 if (AWTEventMonitor.focusListener_private != null) { 1289 AWTEventMonitor.focusListener_private.focusLost(e); 1290 } 1291 } 1292 1293 /* ItemListener Methods *****************************************/ 1294 1295 /** 1296 * Called when an item's state changes. 1297 * @see AWTEventMonitor#addItemListener 1298 */ 1299 public void itemStateChanged(ItemEvent e) { 1300 if (AWTEventMonitor.itemListener_private != null) { 1301 AWTEventMonitor.itemListener_private.itemStateChanged(e); 1302 } 1303 } 1304 1305 /* KeyListener Methods ******************************************/ 1306 1307 /** 1308 * Called when a key is pressed. 1309 * @see AWTEventMonitor#addKeyListener 1310 */ 1311 public void keyPressed(KeyEvent e) { 1312 if (AWTEventMonitor.keyListener_private != null) { 1313 AWTEventMonitor.keyListener_private.keyPressed(e); 1314 } 1315 } 1316 1317 /** 1318 * Called when a key is typed. 1319 * @see AWTEventMonitor#addKeyListener 1320 */ 1321 public void keyReleased(KeyEvent e) { 1322 if (AWTEventMonitor.keyListener_private != null) { 1323 AWTEventMonitor.keyListener_private.keyReleased(e); 1324 } 1325 } 1326 1327 /** 1328 * Called when a key is released. 1329 * @see AWTEventMonitor#addKeyListener 1330 */ 1331 public void keyTyped(KeyEvent e) { 1332 if (AWTEventMonitor.keyListener_private != null) { 1333 AWTEventMonitor.keyListener_private.keyTyped(e); 1334 } 1335 } 1336 1337 /* MouseListener Methods ****************************************/ 1338 1339 /** 1340 * Called when the mouse is clicked. 1341 * @see AWTEventMonitor#addMouseListener 1342 */ 1343 public void mouseClicked(MouseEvent e) { 1344 if (AWTEventMonitor.mouseListener_private != null) { 1345 AWTEventMonitor.mouseListener_private.mouseClicked(e); 1346 } 1347 } 1348 1349 /** 1350 * Called when the mouse enters a component. 1351 * @see AWTEventMonitor#addMouseListener 1352 */ 1353 public void mouseEntered(MouseEvent e) { 1354 if (AWTEventMonitor.mouseListener_private != null) { 1355 AWTEventMonitor.mouseListener_private.mouseEntered(e); 1356 } 1357 } 1358 1359 /** 1360 * Called when the mouse leaves a component. 1361 * @see AWTEventMonitor#addMouseListener 1362 */ 1363 public void mouseExited(MouseEvent e) { 1364 if (AWTEventMonitor.mouseListener_private != null) { 1365 AWTEventMonitor.mouseListener_private.mouseExited(e); 1366 } 1367 } 1368 1369 /** 1370 * Called when the mouse is pressed. 1371 * @see AWTEventMonitor#addMouseListener 1372 */ 1373 public void mousePressed(MouseEvent e) { 1374 if (AWTEventMonitor.mouseListener_private != null) { 1375 AWTEventMonitor.mouseListener_private.mousePressed(e); 1376 } 1377 } 1378 1379 /** 1380 * Called when the mouse is released. 1381 * @see AWTEventMonitor#addMouseListener 1382 */ 1383 public void mouseReleased(MouseEvent e) { 1384 if (AWTEventMonitor.mouseListener_private != null) { 1385 AWTEventMonitor.mouseListener_private.mouseReleased(e); 1386 } 1387 } 1388 1389 /* MouseMotionListener Methods **********************************/ 1390 1391 /** 1392 * Called when the mouse is dragged. 1393 * @see AWTEventMonitor#addMouseMotionListener 1394 */ 1395 public void mouseDragged(MouseEvent e) { 1396 if (AWTEventMonitor.mouseMotionListener_private != null) { 1397 AWTEventMonitor.mouseMotionListener_private.mouseDragged(e); 1398 } 1399 } 1400 1401 /** 1402 * Called when the mouse is moved. 1403 * @see AWTEventMonitor#addMouseMotionListener 1404 */ 1405 public void mouseMoved(MouseEvent e) { 1406 if (AWTEventMonitor.mouseMotionListener_private != null) { 1407 AWTEventMonitor.mouseMotionListener_private.mouseMoved(e); 1408 } 1409 } 1410 1411 /* TextListener Methods *****************************************/ 1412 1413 /** 1414 * Called when a component's text value changed. 1415 * @see AWTEventMonitor#addTextListener 1416 */ 1417 public void textValueChanged(TextEvent e) { 1418 if (AWTEventMonitor.textListener_private != null) { 1419 AWTEventMonitor.textListener_private.textValueChanged(e); 1420 } 1421 } 1422 1423 /* WindowListener Methods ***************************************/ 1424 1425 /** 1426 * Called when a window is opened. 1427 * @see AWTEventMonitor#addWindowListener 1428 */ 1429 public void windowOpened(WindowEvent e) { 1430 if (AWTEventMonitor.windowListener_private != null) { 1431 AWTEventMonitor.windowListener_private.windowOpened(e); 1432 } 1433 } 1434 1435 /** 1436 * Called when a window is in the process of closing. 1437 * @see AWTEventMonitor#addWindowListener 1438 */ 1439 public void windowClosing(WindowEvent e) { 1440 if (AWTEventMonitor.windowListener_private != null) { 1441 AWTEventMonitor.windowListener_private.windowClosing(e); 1442 } 1443 } 1444 1445 /** 1446 * Called when a window is closed. 1447 * @see AWTEventMonitor#addWindowListener 1448 */ 1449 public void windowClosed(WindowEvent e) { 1450 if (AWTEventMonitor.windowListener_private != null) { 1451 AWTEventMonitor.windowListener_private.windowClosed(e); 1452 } 1453 } 1454 1455 /** 1456 * Called when a window is iconified. 1457 * @see AWTEventMonitor#addWindowListener 1458 */ 1459 public void windowIconified(WindowEvent e) { 1460 if (AWTEventMonitor.windowListener_private != null) { 1461 AWTEventMonitor.windowListener_private.windowIconified(e); 1462 } 1463 } 1464 1465 /** 1466 * Called when a window is deiconified. 1467 * @see AWTEventMonitor#addWindowListener 1468 */ 1469 public void windowDeiconified(WindowEvent e) { 1470 if (AWTEventMonitor.windowListener_private != null) { 1471 AWTEventMonitor.windowListener_private.windowDeiconified(e); 1472 } 1473 } 1474 1475 /** 1476 * Called when a window is activated. 1477 * @see AWTEventMonitor#addWindowListener 1478 */ 1479 public void windowActivated(WindowEvent e) { 1480 if (AWTEventMonitor.windowListener_private != null) { 1481 AWTEventMonitor.windowListener_private.windowActivated(e); 1482 } 1483 } 1484 1485 /** 1486 * Called when a window is deactivated. 1487 * @see AWTEventMonitor#addWindowListener 1488 */ 1489 public void windowDeactivated(WindowEvent e) { 1490 if (AWTEventMonitor.windowListener_private != null) { 1491 AWTEventMonitor.windowListener_private.windowDeactivated(e); 1492 } 1493 } 1494 } 1495 }