Name: stC104175 Date: 05/15/2000
Symantec Java! JustInTime Compiler Version 4.00.006(x) for JDK 1.2 (Symantec GC)
Copyright (C) 1996-99 Symantec Corporation
java version "1.2.2.Symc"
Classic VM (build 1.2.2.Symc, native threads, symantec gc, symcjit)
DefaultListSelectionModel.insertIndexInterval() should update leadIndex and
anchorIndex.
That is, ...
public void insertIndexInterval(int index, int length, boolean before)
{
....
// Following codes should be appended.
if (anchorIndex >= insMinIndex)
anchorIndex += length;
if (leadIndex >= insMinIndex)
leadIndex += length;
}
Also
Symantec Java! JustInTime Compiler Version 4.00.006(x) for JDK 1.2 (Symantec GC)
Copyright (C) 1996-99 Symantec Corporation
java version "1.2.2.Symc"
Classic VM (build 1.2.2.Symc, native threads, symantec gc, symcjit)
DefaultListSelectionModel.removeIndexInterval() should update leadIndex and
anchorIndex.
That is, ...
public void removeIndexInterval(int index0, int index1)
{
....
// Following codes should be appended.
if (anchorIndex > rmMaxIndex)
anchorIndex -= gapLength;
else if (anchorIndex >= rmMinIndex)
anchorIndex = -1;
if (leadIndex > rmMaxIndex)
leadIndex -= gapLength;
else if (leadIndex >= rmMinIndex)
leadIndex = -1;
}
(Review ID: 104869)
======================================================================
Name: apR10133 Date: 12/05/2001
Here is the testcase so show the problem.
------------------------- test.java -----------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class test {
JList lst;
DefaultListSelectionModel lsm;
DefaultListModel lm;
JTextField first, length;
public test() {
JFrame fr = new JFrame("Test");
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String [] data = {"null", "one", "two", "three",
"four", "five", "six", "seven"};
lst = new JList(data);
JScrollPane sp = new JScrollPane(lst);
lm = new DefaultListModel();
for (int i=0; i<10; i++) {
lm.addElement("Element "+i);
}
lst.setModel(lm);
lsm = new DefaultListSelectionModel();
lst.setSelectionModel(lsm);
lst.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
fr.getContentPane().add(sp);
JPanel p = new JPanel();
fr.getContentPane().add(p, BorderLayout.SOUTH);
p.setLayout(new GridLayout(2,4));
first = new JTextField("1");
p.add(new JLabel("Start with"));
p.add(first);
length = new JTextField("1");
p.add(new JLabel("Length"));
p.add(length);
JButton bt = new JButton("Print");
p.add(bt);
bt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("A: "+lst.getAnchorSelectionIndex());
System.out.println("L: "+lst.getLeadSelectionIndex());
}
});
JButton ins = new JButton("Insert");
p.add(ins);
ins.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
int i0 = Integer.parseInt(first.getText());
int len = Integer.parseInt(length.getText());
for (int i=0; i<len; i++) {
lm.insertElementAt("Element...", i0+i);
}
lst.updateUI();
} catch (Exception exc) {
exc.printStackTrace();
}
}
});
JButton rem = new JButton("Remove");
p.add(rem);
rem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
int i0 = Integer.parseInt(first.getText());
int len = Integer.parseInt(length.getText());
lm.removeRange(i0, i0+len-1);
lst.updateUI();
} catch (Exception exc) {
exc.printStackTrace();
}
}
});
fr.setSize(400,200);
fr.setVisible(true);
}
public static void main(String[] argv) {
test b = new test();
}
}
-----------------------------------------------------------
======================================================================