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

java.awt.List events are not sent properly to handleEvent or ItemListener

    Details

    • Subcomponent:
    • Resolved In Build:
      b116
    • CPU:
      x86
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      1.7.0_05-b06

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7600]

      A DESCRIPTION OF THE PROBLEM :
      Events passed to handleEvent or ItemListener for a java.awt.List are incorrect.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a java.awt.List Component with preselected items. Then select or deselect items and print the result event passed to handle event using the toString method. the information contained in the event will be incorrect in terms of the index of the item being interacted with and the id of event (Event.LIST_SELECT or Event.LIST_DESELECT).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect to see the correct event information.
      ACTUAL -
      Incorrect event information.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      None just incorrect results.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
      See http://www.stat.tamu.edu/~west/listtest.html
      */

      import java.awt.*;
      import java.applet.Applet;
      import java.awt.event.*;

      public class ListExample extends java.applet.Applet{

      TextArea ta = new TextArea("",5,50,TextArea.SCROLLBARS_BOTH);
      List variables;

      public void init(){
      setLayout(new BorderLayout());
      variables = new List(7,true);
      variables.addItem("One");
      variables.addItem("Two");
      variables.addItem("Three");
      variables.addItem("Four");
      variables.select(0);
      variables.select(1);
      variables.select(2);
      variables.select(3);
      add("Center",variables);
      add("South",ta);
      }

        public boolean handleEvent(Event e) {
         if(e.target instanceof List){
      if (e.id == Event.LIST_DESELECT) {
      ta.append("List deselected at index "+e.arg.toString());
      }else if(e.id == Event.LIST_SELECT) {
      ta.append("List selected at index "+e.arg.toString());
      }
      ta.append("\n");
      }
      return super.handleEvent(e);
        }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The only workaround I have found is to store the selected indexes after each event in another vector and then compare it each time with the current value from the getSelectedIndexes method for the List.

      SUPPORT :
      YES

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                arapte Ambarish Rapte
                Reporter:
                serb Sergey Bylokhov
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: