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.awt.AWTPermissions; 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(AWTPermissions.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 actionListeners = new java.lang.Class<?>[1]; 658 actionArgs = new java.lang.Object[1]; 659 actionListeners[0] = java.awt.event.ActionListener.class; 660 actionArgs[0] = this; 661 662 itemListeners = new java.lang.Class<?>[1]; 663 itemArgs = new java.lang.Object[1]; 664 itemListeners[0] = java.awt.event.ItemListener.class; 665 itemArgs[0] = this; 666 667 textListeners = new java.lang.Class<?>[1]; 668 textArgs = new java.lang.Object[1]; 669 textListeners[0] = java.awt.event.TextListener.class; 670 textArgs[0] = this; 671 672 windowListeners = new java.lang.Class<?>[1]; 673 windowArgs = new java.lang.Object[1]; 674 windowListeners[0] = java.awt.event.WindowListener.class; 675 windowArgs[0] = this; 676 677 return true; 678 } 679 680 /** 681 * Installs all currently registered listeners on all components based 682 * upon the current topLevelWindows cached by EventQueueMonitor. 683 * 684 * @see EventQueueMonitor 685 * @see AWTEventMonitor 686 */ 687 protected void installListeners() { 688 Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); 689 if (topLevelWindows != null) { 690 for (int i = 0; i < topLevelWindows.length; i++) { 691 installListeners(topLevelWindows[i]); 692 } 693 } 694 } 695 696 /** 697 * Installs listeners for the given event ID on all components based 698 * upon the current topLevelWindows cached by EventQueueMonitor. 699 * 700 * @param eventID the event ID 701 * @see EventID 702 */ 703 protected void installListeners(int eventID) { 704 Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); 705 if (topLevelWindows != null) { 706 for (int i = 0; i < topLevelWindows.length; i++) { 707 installListeners(topLevelWindows[i], eventID); 708 } 709 } 710 } 711 712 /** 713 * Installs all currently registered listeners to just the component. 714 * @param c the component to add listeners to 715 */ 716 protected void installListeners(Component c) { 717 718 // Container and focus listeners are always installed for our own use. 719 // 720 installListeners(c,EventID.CONTAINER); 721 installListeners(c,EventID.FOCUS); 722 723 // conditionally install low-level listeners 724 // 725 if (AWTEventMonitor.componentListener_private != null) { 726 installListeners(c,EventID.COMPONENT); 727 } 728 if (AWTEventMonitor.keyListener_private != null) { 729 installListeners(c,EventID.KEY); 730 } 731 if (AWTEventMonitor.mouseListener_private != null) { 732 installListeners(c,EventID.MOUSE); 733 } 734 if (AWTEventMonitor.mouseMotionListener_private != null) { 735 installListeners(c,EventID.MOTION); 736 } 737 if (AWTEventMonitor.windowListener_private != null) { 738 installListeners(c,EventID.WINDOW); 739 } 740 741 // conditionally install Semantic listeners 742 // 743 if (AWTEventMonitor.actionListener_private != null) { 744 installListeners(c,EventID.ACTION); 745 } 746 if (AWTEventMonitor.adjustmentListener_private != null) { 747 installListeners(c,EventID.ADJUSTMENT); 748 } 749 if (AWTEventMonitor.itemListener_private != null) { 750 installListeners(c,EventID.ITEM); 751 } 752 if (AWTEventMonitor.textListener_private != null) { 753 installListeners(c,EventID.TEXT); 754 } 755 } 756 757 public void stateChanged(ChangeEvent e) { 758 processFocusGained(); 759 } 760 761 private void processFocusGained() { 762 Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); 763 if (focusOwner == null) { 764 return; 765 } 766 MenuSelectionManager.defaultManager().removeChangeListener(this); 767 MenuSelectionManager.defaultManager().addChangeListener(this); 768 769 // Only menus and popup selections are handled by the JRootPane. 770 if (focusOwner instanceof JRootPane) { 771 MenuElement [] path = 772 MenuSelectionManager.defaultManager().getSelectedPath(); 773 if (path.length > 1) { 774 Component penult = path[path.length-2].getComponent(); 775 Component last = path[path.length-1].getComponent(); 776 777 if (last instanceof JPopupMenu || 778 last instanceof JMenu) { 779 // This is a popup with nothing in the popup 780 // selected. The menu itself is selected. 781 componentWithFocus_private = last; 782 } else if (penult instanceof JPopupMenu) { 783 // This is a popup with an item selected 784 componentWithFocus_private = penult; 785 } 786 } 787 } else { 788 // The focus owner has the selection. 789 componentWithFocus_private = focusOwner; 790 } 791 } 792 793 /** 794 * Installs the given listener on the component and any of its children. 795 * As a precaution, it always attempts to remove itself as a listener 796 * first so it's always guaranteed to have installed itself just once. 797 * 798 * @param c the component to add listeners to 799 * @param eventID the eventID to add listeners for 800 * @see EventID 801 */ 802 protected void installListeners(Component c, int eventID) { 803 804 // install the appropriate listener hook into this component 805 // 806 switch (eventID) { 807 808 case EventID.ACTION: 809 try { 810 removeActionMethod = c.getClass().getMethod( 811 "removeActionListener", actionListeners); 812 addActionMethod = c.getClass().getMethod( 813 "addActionListener", actionListeners); 814 try { 815 removeActionMethod.invoke(c, actionArgs); 816 addActionMethod.invoke(c, actionArgs); 817 } catch (java.lang.reflect.InvocationTargetException e) { 818 System.out.println("Exception: " + e.toString()); 819 } catch (IllegalAccessException e) { 820 System.out.println("Exception: " + e.toString()); 821 } 822 } catch (NoSuchMethodException e) { 823 // System.out.println("Exception: " + e.toString()); 824 } catch (SecurityException e) { 825 System.out.println("Exception: " + e.toString()); 826 } 827 break; 828 829 case EventID.ADJUSTMENT: 830 if (c instanceof Adjustable) { 831 ((Adjustable) c).removeAdjustmentListener(this); 832 ((Adjustable) c).addAdjustmentListener(this); 833 } 834 break; 835 836 case EventID.COMPONENT: 837 c.removeComponentListener(this); 838 c.addComponentListener(this); 839 break; 840 841 case EventID.CONTAINER: 842 if (c instanceof Container) { 843 ((Container) c).removeContainerListener(this); 844 ((Container) c).addContainerListener(this); 845 } 846 break; 847 848 case EventID.FOCUS: 849 c.removeFocusListener(this); 850 c.addFocusListener(this); 851 852 if (runningOnJDK1_4) { 853 processFocusGained(); 854 855 } else { // not runningOnJDK1_4 856 if ((c != componentWithFocus_private) && c.hasFocus()) { 857 componentWithFocus_private = c; 858 } 859 } 860 break; 861 862 case EventID.ITEM: 863 try { 864 removeItemMethod = c.getClass().getMethod( 865 "removeItemListener", itemListeners); 866 addItemMethod = c.getClass().getMethod( 867 "addItemListener", itemListeners); 868 try { 869 removeItemMethod.invoke(c, itemArgs); 870 addItemMethod.invoke(c, itemArgs); 871 } catch (java.lang.reflect.InvocationTargetException e) { 872 System.out.println("Exception: " + e.toString()); 873 } catch (IllegalAccessException e) { 874 System.out.println("Exception: " + e.toString()); 875 } 876 } catch (NoSuchMethodException e) { 877 // System.out.println("Exception: " + e.toString()); 878 } catch (SecurityException e) { 879 System.out.println("Exception: " + e.toString()); 880 } 881 // [PK] CheckboxMenuItem isn't a component but it does 882 // implement Interface ItemSelectable!! 883 // if (c instanceof CheckboxMenuItem) { 884 // ((CheckboxMenuItem) c).removeItemListener(this); 885 // ((CheckboxMenuItem) c).addItemListener(this); 886 break; 887 888 case EventID.KEY: 889 c.removeKeyListener(this); 890 c.addKeyListener(this); 891 break; 892 893 case EventID.MOUSE: 894 c.removeMouseListener(this); 895 c.addMouseListener(this); 896 break; 897 898 case EventID.MOTION: 899 c.removeMouseMotionListener(this); 900 c.addMouseMotionListener(this); 901 break; 902 903 case EventID.TEXT: 904 try { 905 removeTextMethod = c.getClass().getMethod( 906 "removeTextListener", textListeners); 907 addTextMethod = c.getClass().getMethod( 908 "addTextListener", textListeners); 909 try { 910 removeTextMethod.invoke(c, textArgs); 911 addTextMethod.invoke(c, textArgs); 912 } catch (java.lang.reflect.InvocationTargetException e) { 913 System.out.println("Exception: " + e.toString()); 914 } catch (IllegalAccessException e) { 915 System.out.println("Exception: " + e.toString()); 916 } 917 } catch (NoSuchMethodException e) { 918 // System.out.println("Exception: " + e.toString()); 919 } catch (SecurityException e) { 920 System.out.println("Exception: " + e.toString()); 921 } 922 break; 923 924 case EventID.WINDOW: 925 try { 926 removeWindowMethod = c.getClass().getMethod( 927 "removeWindowListener", windowListeners); 928 addWindowMethod = c.getClass().getMethod( 929 "addWindowListener", windowListeners); 930 try { 931 removeWindowMethod.invoke(c, windowArgs); 932 addWindowMethod.invoke(c, windowArgs); 933 } catch (java.lang.reflect.InvocationTargetException e) { 934 System.out.println("Exception: " + e.toString()); 935 } catch (IllegalAccessException e) { 936 System.out.println("Exception: " + e.toString()); 937 } 938 } catch (NoSuchMethodException e) { 939 // System.out.println("Exception: " + e.toString()); 940 } catch (SecurityException e) { 941 System.out.println("Exception: " + e.toString()); 942 } 943 break; 944 945 // Don't bother recursing the children if this isn't going to 946 // accomplish anything. 947 // 948 default: 949 return; 950 } 951 952 // if this component is a container, recurse through children 953 // 954 if (c instanceof Container) { 955 int count = ((Container) c).getComponentCount(); 956 for (int i = 0; i < count; i++) { 957 installListeners(((Container) c).getComponent(i), eventID); 958 } 959 } 960 } 961 962 /** 963 * Removes all listeners for the given event ID on all components based 964 * upon the topLevelWindows cached by EventQueueMonitor. 965 * 966 * @param eventID the event ID 967 * @see EventID 968 */ 969 protected void removeListeners(int eventID) { 970 Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); 971 if (topLevelWindows != null) { 972 for (int i = 0; i < topLevelWindows.length; i++) { 973 removeListeners(topLevelWindows[i], eventID); 974 } 975 } 976 } 977 978 /** 979 * Removes all listeners for the given component and all its children. 980 * @param c the component 981 */ 982 protected void removeListeners(Component c) { 983 984 // conditionally remove low-level listeners 985 // 986 if (AWTEventMonitor.componentListener_private != null) { 987 removeListeners(c,EventID.COMPONENT); 988 } 989 if (AWTEventMonitor.keyListener_private != null) { 990 removeListeners(c,EventID.KEY); 991 } 992 if (AWTEventMonitor.mouseListener_private != null) { 993 removeListeners(c,EventID.MOUSE); 994 } 995 if (AWTEventMonitor.mouseMotionListener_private != null) { 996 removeListeners(c,EventID.MOTION); 997 } 998 if (AWTEventMonitor.windowListener_private != null) { 999 removeListeners(c,EventID.WINDOW); 1000 } 1001 1002 // Remove semantic listeners 1003 // 1004 if (AWTEventMonitor.actionListener_private != null) { 1005 removeListeners(c,EventID.ACTION); 1006 } 1007 if (AWTEventMonitor.adjustmentListener_private != null) { 1008 removeListeners(c,EventID.ADJUSTMENT); 1009 } 1010 if (AWTEventMonitor.itemListener_private != null) { 1011 removeListeners(c,EventID.ITEM); 1012 } 1013 if (AWTEventMonitor.textListener_private != null) { 1014 removeListeners(c,EventID.TEXT); 1015 } 1016 } 1017 1018 /** 1019 * Removes all listeners for the event ID from the component and all 1020 * of its children. 1021 * 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 * 1165 * @see EventQueueMonitor 1166 * @see EventQueueMonitor#addTopLevelWindowListener 1167 */ 1168 public void topLevelWindowCreated(Window w) { 1169 installListeners(w); 1170 } 1171 1172 /** 1173 * Called when top level window is destroyed. 1174 * 1175 * @see EventQueueMonitor 1176 * @see EventQueueMonitor#addTopLevelWindowListener 1177 */ 1178 public void topLevelWindowDestroyed(Window w) { 1179 } 1180 1181 /* ActionListener Methods ***************************************/ 1182 1183 /** 1184 * Called when an action is performed. 1185 * 1186 * @see AWTEventMonitor#addActionListener 1187 */ 1188 public void actionPerformed(ActionEvent e) { 1189 if (AWTEventMonitor.actionListener_private != null) { 1190 AWTEventMonitor.actionListener_private.actionPerformed(e); 1191 } 1192 } 1193 1194 /* AdjustmentListener Methods ***********************************/ 1195 1196 /** 1197 * Called when an adjustment is made. 1198 * 1199 * @see AWTEventMonitor#addAdjustmentListener 1200 */ 1201 public void adjustmentValueChanged(AdjustmentEvent e) { 1202 if (AWTEventMonitor.adjustmentListener_private != null) { 1203 AWTEventMonitor.adjustmentListener_private.adjustmentValueChanged(e); 1204 } 1205 } 1206 1207 /* ComponentListener Methods ************************************/ 1208 1209 /** 1210 * Called when a component is hidden. 1211 * 1212 * @see AWTEventMonitor#addComponentListener 1213 */ 1214 public void componentHidden(ComponentEvent e) { 1215 if (AWTEventMonitor.componentListener_private != null) { 1216 AWTEventMonitor.componentListener_private.componentHidden(e); 1217 } 1218 } 1219 1220 /** 1221 * Called when a component is moved. 1222 * 1223 * @see AWTEventMonitor#addComponentListener 1224 */ 1225 public void componentMoved(ComponentEvent e) { 1226 if (AWTEventMonitor.componentListener_private != null) { 1227 AWTEventMonitor.componentListener_private.componentMoved(e); 1228 } 1229 } 1230 1231 /** 1232 * Called when a component is resized. 1233 * 1234 * @see AWTEventMonitor#addComponentListener 1235 */ 1236 public void componentResized(ComponentEvent e) { 1237 if (AWTEventMonitor.componentListener_private != null) { 1238 AWTEventMonitor.componentListener_private.componentResized(e); 1239 } 1240 } 1241 1242 /** 1243 * Called when a component is shown. 1244 * 1245 * @see AWTEventMonitor#addComponentListener 1246 */ 1247 public void componentShown(ComponentEvent e) { 1248 if (AWTEventMonitor.componentListener_private != null) { 1249 AWTEventMonitor.componentListener_private.componentShown(e); 1250 } 1251 } 1252 1253 /* ContainerListener Methods ************************************/ 1254 1255 /** 1256 * Called when a component is added to a container. 1257 * 1258 * @see AWTEventMonitor#addContainerListener 1259 */ 1260 public void componentAdded(ContainerEvent e) { 1261 installListeners(e.getChild()); 1262 if (AWTEventMonitor.containerListener_private != null) { 1263 AWTEventMonitor.containerListener_private.componentAdded(e); 1264 } 1265 } 1266 1267 /** 1268 * Called when a component is removed from a container. 1269 * 1270 * @see AWTEventMonitor#addContainerListener 1271 */ 1272 public void componentRemoved(ContainerEvent e) { 1273 removeListeners(e.getChild()); 1274 if (AWTEventMonitor.containerListener_private != null) { 1275 AWTEventMonitor.containerListener_private.componentRemoved(e); 1276 } 1277 } 1278 1279 /* FocusListener Methods ****************************************/ 1280 1281 /** 1282 * Called when a component gains keyboard focus. 1283 * 1284 * @see AWTEventMonitor#addFocusListener 1285 */ 1286 public void focusGained(FocusEvent e) { 1287 AWTEventMonitor.componentWithFocus_private = (Component) e.getSource(); 1288 if (AWTEventMonitor.focusListener_private != null) { 1289 AWTEventMonitor.focusListener_private.focusGained(e); 1290 } 1291 } 1292 1293 /** 1294 * Called when a component loses keyboard focus. 1295 * 1296 * @see AWTEventMonitor#addFocusListener 1297 */ 1298 public void focusLost(FocusEvent e) { 1299 AWTEventMonitor.componentWithFocus_private = null; 1300 if (AWTEventMonitor.focusListener_private != null) { 1301 AWTEventMonitor.focusListener_private.focusLost(e); 1302 } 1303 } 1304 1305 /* ItemListener Methods *****************************************/ 1306 1307 /** 1308 * Called when an item's state changes. 1309 * 1310 * @see AWTEventMonitor#addItemListener 1311 */ 1312 public void itemStateChanged(ItemEvent e) { 1313 if (AWTEventMonitor.itemListener_private != null) { 1314 AWTEventMonitor.itemListener_private.itemStateChanged(e); 1315 } 1316 } 1317 1318 /* KeyListener Methods ******************************************/ 1319 1320 /** 1321 * Called when a key is pressed. 1322 * 1323 * @see AWTEventMonitor#addKeyListener 1324 */ 1325 public void keyPressed(KeyEvent e) { 1326 if (AWTEventMonitor.keyListener_private != null) { 1327 AWTEventMonitor.keyListener_private.keyPressed(e); 1328 } 1329 } 1330 1331 /** 1332 * Called when a key is typed. 1333 * 1334 * @see AWTEventMonitor#addKeyListener 1335 */ 1336 public void keyReleased(KeyEvent e) { 1337 if (AWTEventMonitor.keyListener_private != null) { 1338 AWTEventMonitor.keyListener_private.keyReleased(e); 1339 } 1340 } 1341 1342 /** 1343 * Called when a key is released. 1344 * 1345 * @see AWTEventMonitor#addKeyListener 1346 */ 1347 public void keyTyped(KeyEvent e) { 1348 if (AWTEventMonitor.keyListener_private != null) { 1349 AWTEventMonitor.keyListener_private.keyTyped(e); 1350 } 1351 } 1352 1353 /* MouseListener Methods ****************************************/ 1354 1355 /** 1356 * Called when the mouse is clicked. 1357 * 1358 * @see AWTEventMonitor#addMouseListener 1359 */ 1360 public void mouseClicked(MouseEvent e) { 1361 if (AWTEventMonitor.mouseListener_private != null) { 1362 AWTEventMonitor.mouseListener_private.mouseClicked(e); 1363 } 1364 } 1365 1366 /** 1367 * Called when the mouse enters a component. 1368 * 1369 * @see AWTEventMonitor#addMouseListener 1370 */ 1371 public void mouseEntered(MouseEvent e) { 1372 if (AWTEventMonitor.mouseListener_private != null) { 1373 AWTEventMonitor.mouseListener_private.mouseEntered(e); 1374 } 1375 } 1376 1377 /** 1378 * Called when the mouse leaves a component. 1379 * 1380 * @see AWTEventMonitor#addMouseListener 1381 */ 1382 public void mouseExited(MouseEvent e) { 1383 if (AWTEventMonitor.mouseListener_private != null) { 1384 AWTEventMonitor.mouseListener_private.mouseExited(e); 1385 } 1386 } 1387 1388 /** 1389 * Called when the mouse is pressed. 1390 * 1391 * @see AWTEventMonitor#addMouseListener 1392 */ 1393 public void mousePressed(MouseEvent e) { 1394 if (AWTEventMonitor.mouseListener_private != null) { 1395 AWTEventMonitor.mouseListener_private.mousePressed(e); 1396 } 1397 } 1398 1399 /** 1400 * Called when the mouse is released. 1401 * 1402 * @see AWTEventMonitor#addMouseListener 1403 */ 1404 public void mouseReleased(MouseEvent e) { 1405 if (AWTEventMonitor.mouseListener_private != null) { 1406 AWTEventMonitor.mouseListener_private.mouseReleased(e); 1407 } 1408 } 1409 1410 /* MouseMotionListener Methods **********************************/ 1411 1412 /** 1413 * Called when the mouse is dragged. 1414 * 1415 * @see AWTEventMonitor#addMouseMotionListener 1416 */ 1417 public void mouseDragged(MouseEvent e) { 1418 if (AWTEventMonitor.mouseMotionListener_private != null) { 1419 AWTEventMonitor.mouseMotionListener_private.mouseDragged(e); 1420 } 1421 } 1422 1423 /** 1424 * Called when the mouse is moved. 1425 * 1426 * @see AWTEventMonitor#addMouseMotionListener 1427 */ 1428 public void mouseMoved(MouseEvent e) { 1429 if (AWTEventMonitor.mouseMotionListener_private != null) { 1430 AWTEventMonitor.mouseMotionListener_private.mouseMoved(e); 1431 } 1432 } 1433 1434 /* TextListener Methods *****************************************/ 1435 1436 /** 1437 * Called when a component's text value changed. 1438 * 1439 * @see AWTEventMonitor#addTextListener 1440 */ 1441 public void textValueChanged(TextEvent e) { 1442 if (AWTEventMonitor.textListener_private != null) { 1443 AWTEventMonitor.textListener_private.textValueChanged(e); 1444 } 1445 } 1446 1447 /* WindowListener Methods ***************************************/ 1448 1449 /** 1450 * Called when a window is opened. 1451 * 1452 * @see AWTEventMonitor#addWindowListener 1453 */ 1454 public void windowOpened(WindowEvent e) { 1455 if (AWTEventMonitor.windowListener_private != null) { 1456 AWTEventMonitor.windowListener_private.windowOpened(e); 1457 } 1458 } 1459 1460 /** 1461 * Called when a window is in the process of closing. 1462 * 1463 * @see AWTEventMonitor#addWindowListener 1464 */ 1465 public void windowClosing(WindowEvent e) { 1466 if (AWTEventMonitor.windowListener_private != null) { 1467 AWTEventMonitor.windowListener_private.windowClosing(e); 1468 } 1469 } 1470 1471 /** 1472 * Called when a window is closed. 1473 * 1474 * @see AWTEventMonitor#addWindowListener 1475 */ 1476 public void windowClosed(WindowEvent e) { 1477 if (AWTEventMonitor.windowListener_private != null) { 1478 AWTEventMonitor.windowListener_private.windowClosed(e); 1479 } 1480 } 1481 1482 /** 1483 * Called when a window is iconified. 1484 * 1485 * @see AWTEventMonitor#addWindowListener 1486 */ 1487 public void windowIconified(WindowEvent e) { 1488 if (AWTEventMonitor.windowListener_private != null) { 1489 AWTEventMonitor.windowListener_private.windowIconified(e); 1490 } 1491 } 1492 1493 /** 1494 * Called when a window is deiconified. 1495 * 1496 * @see AWTEventMonitor#addWindowListener 1497 */ 1498 public void windowDeiconified(WindowEvent e) { 1499 if (AWTEventMonitor.windowListener_private != null) { 1500 AWTEventMonitor.windowListener_private.windowDeiconified(e); 1501 } 1502 } 1503 1504 /** 1505 * Called when a window is activated. 1506 * 1507 * @see AWTEventMonitor#addWindowListener 1508 */ 1509 public void windowActivated(WindowEvent e) { 1510 if (AWTEventMonitor.windowListener_private != null) { 1511 AWTEventMonitor.windowListener_private.windowActivated(e); 1512 } 1513 } 1514 1515 /** 1516 * Called when a window is deactivated. 1517 * 1518 * @see AWTEventMonitor#addWindowListener 1519 */ 1520 public void windowDeactivated(WindowEvent e) { 1521 if (AWTEventMonitor.windowListener_private != null) { 1522 AWTEventMonitor.windowListener_private.windowDeactivated(e); 1523 } 1524 } 1525 } 1526 }