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

getFirstIndex() does not return the first index that has changed

XMLWordPrintable

    • b32
    • x86
    • windows_xp

        FULL PRODUCT VERSION :
        J2SEE 6

        ADDITIONAL OS VERSION INFORMATION :
        Windows XP

        A DESCRIPTION OF THE PROBLEM :
        An api that worked fine in JDK 1.4 is not working corrctly in 1.6:
        The method getFirstIndex() on ListSelectionEvent. that has been working fine on JDK 1.4 is no longer working as expected in 1.6

        The following code when executed in 1.4 return the row whose selection status was changed.

                if (e.getSource() == orderTable.getSelectionModel() &&
                    e.getFirstIndex() >= 0 && e.getValueIsAdjusting() == false)
                {
                   .....
                 .......
                }

        In JDK i.6 if the event is triggered programatically likke by aTable.selectAll(), e.getFirstIndex() returns a -1 instead of the row that was selected.

        REGRESSION. Last worked in version 1.4.2

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Assign a selection model to a jtable like
            ListSelectionModel selectionModel = orderTable.getSelectionModel();
            selectionModel.setSelectionMode(ListSelectionModel.
                                            MULTIPLE_INTERVAL_SELECTION);
        // jScrollPane1.getViewport().add(orderTable, null);
        // orderTable.setOpaque(false);
            selectionModel.addListSelectionListener(new ListSelectionListener()
            {
              public void valueChanged(ListSelectionEvent e)
              {
                if (e.getSource() == orderTable.getSelectionModel() &&
                    e.getFirstIndex() >= 0 && e.getValueIsAdjusting() == false)
                {
                  setOrderTableButtonState();
                  setSkuForPendingOrderDataVector(
                      convertSkuDetailForPendingAllocationOrderListToVector(
                      getSkuDetailForSelectedSplitOrders()));

                }

              }
            });



        and ten programatically call selectAl() on the table.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
         e.getFirstIndex() returns0
        ACTUAL -
         e.getFirstIndex() e.getFirstIndex() returns -1

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
                                            MULTIPLE_INTERVAL_SELECTION);
        // jScrollPane1.getViewport().add(orderTable, null);
        // orderTable.setOpaque(false);
            selectionModel.addListSelectionListener(new ListSelectionListener()
            {
              public void valueChanged(ListSelectionEvent e)
              {
                if (e.getSource() == orderTable.getSelectionModel() &&
                    e.getFirstIndex() >= 0 && e.getValueIsAdjusting() == false)
                {
                  setOrderTableButtonState();
                  setSkuForPendingOrderDataVector(
                      convertSkuDetailForPendingAllocationOrderListToVector(
                      getSkuDetailForSelectedSplitOrders()));

                }

              }
            });


         orderTable.selectAll();

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

        CUSTOMER SUBMITTED WORKAROUND :
        Dont use e.getFirstIndex() >= 0

              rupashka Pavel Porvatov (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: