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