Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4977387

DOC:AWTEvtListener differs from other EvtListeners in AWT w.r.t evt notification

XMLWordPrintable

    • Fix Understood
    • generic
    • generic

      1. When a same instance of an AWTEventListener is added multiple times, the toolkit class internally maintains only a single instance of the listener and 'OR's the new event mask with the existing one. So this will typically result in listener methods being notified only once regardless of how many times we add the same instance.
      But in case of other listeners such as ActionListener, TextListener etc when we add the same instance of the listener multiple times to the same component, all the occurances of the listener would be maintained and will be notified when the event is triggered.

      2. Likewise, When we remove an instance of ActionListener/TextListener etc that was added twice, only the last occurance would be removed and other occurances of the same instance would still be maintained. But this is not the case with
      AWTEventListener where only one occurance is maintained internally and
      that gets removed.

      Since AWTEventListener behavior is much different from other listeners available in AWT, it would be better to document this behavior in the toolkit class for better clarity.

            denis Denis Fokin (Inactive)
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: