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

Specification for ListSelectionEvent and other JList support classes must be updated

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P5
    • Resolution: Unresolved
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • Understanding:
      Cause Known
    • CPU:
      generic
    • OS:
      generic

      Description

      ListSelectionEvent should mention more clearly that it tracks all the changes in selection - selections AND unselections of the elements. Perfectly, there must be some examples included.

      Consider the following code:

              final JList jList = new JList(new Integer[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} );
              jList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
              jList.addListSelectionListener(new ListSelectionListener() {
                  public void valueChanged(ListSelectionEvent e) {
                      System.out.println("Selected: " + Arrays.toString(jList.getSelectedIndices()));
                      System.out.println("first = " + e.getFirstIndex() + ", last = " + e.getLastIndex());
                  }
              });
              jList.setSelectionInterval(7, 9);
              jList.addSelectionInterval(2, 3);


      The output is:

      Selected: [7, 8, 9]
      first = 7, last = 9
      Selected: [2, 3]
      first = 2, last = 9

      One may expect the last line to be "first = 2, last = 3".

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dbessono Dmitry Bessonov
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: