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

Undocumented: ListSelectionModel.clearSelection() fires events with indices = -1

XMLWordPrintable

    • beta
    • generic, x86
    • generic, windows_95



      Name: rk38400 Date: 05/20/98


      Swing 1.0.2 under JDK 1.1.6:

      In circumstances where ListSelectionModel.clearSelection()
      is called, listeners are messaged with ListSelectionEvent
      firstIndex and lastIndex = -1; yet misleadingly this isn't
      documented.
      (Review ID: 30817)
      ======================================================================

      Name: krT82822 Date: 06/22/99


      DefaultListSelectionModel: breaks SINGLE_SELECTION in setLeadSelectionIndex

      Assuming a DefaultListSelectionModel in mode SINGLE_SELECTION that
      once had a selection which was removed we get multiple selections
      by setting the lead twice (jdk117, swing111beta1):

      Example:

      import javax.swing.*;

      public class TestSingleSelection {
        DefaultListSelectionModel selection = new DefaultListSelectionModel();

        public TestSingleSelection() {
          selection.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
          selection.setSelectionInterval(0, 0);
          // without removing, everything's ok
          selection.removeSelectionInterval(0, 0);
          selection.setLeadSelectionIndex(2);
          System.out.println(selection.getMinSelectionIndex() + " " +
      selection.getMaxSelectionIndex());
          selection.setLeadSelectionIndex(3);
          System.out.println(selection.getMinSelectionIndex() + " " +
      selection.getMaxSelectionIndex());
        }

      //---------------------------Main

      public static void main(String[] args) {
      new TestSingleSelection();
      }

      } // end class TestSingleSelection


      Greetings
      Jeanette
      (Review ID: 53839)
      ======================================================================

            sswingtrsunw Swingtraq Swingtraq (Inactive)
            rkarsunw Ralph Kar (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: