JDK-6270690 : REGRESSION: JTable ListSelection Model or Key/Mouse event improper func.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-05-16
  • Updated: 2010-04-02
  • Resolved: 2005-07-20
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
all the JRE 1.5 versions even the latest

FULL OS VERSION :
Windows XP

EXTRA RELEVANT SYSTEM CONFIGURATION :
This bug happens on all my clients machines so you should be able to reproduce it very easily.

A DESCRIPTION OF THE PROBLEM :
A fully loaded JTable inside of a JScrollPane when multiple selections are made with the <Cntrl> key down after several random selections are made it will deselect all previous selections as though the <Cntrl> was not pressed. This happens randomly after 3 to 10 selections are made. It happens on other machines than just one and stops happening when I go back to the 1.4 JVM. I have reproduced this bug with the DefaultTableModel loaded to 25 columns and a thousand rows. I can send you a jar file with example code to demo it if you like. I have found other flakey things about the version also and at here at Bellsouth we can't use your new JVM until these issues are addressed.

THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try

REGRESSION.  Last worked in version mustang

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Take the code I pasted below although it is just filling a DefaultTableModel with 25 columns and a thousand rows and displaying it in a JScrollPane. Run it and hold the <Ctrl> down and start selecting. Keep the control key down and eventually all your previous selections will disapear. Usually after several selections have been made. Sometimes after scrolling to view more rows. Make certain to select mulptiple intervals.

EXPECTED VERSUS ACTUAL BEHAVIOR :
I expect that when the <Cntrl> key is held down the previous selections will be preserved like in the 1.4.2 JVM

This does not happen.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error or exception messages raised.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package com.bugs.jdk5;

import javax.swing.*;
import java.awt.*;
import java.util.*;
import javax.swing.table.*;

public class SwingDemo
    extends JFrame
{
    protected JScrollPane jScrollPane1 = new JScrollPane();
    protected JTable table = new JTable();

    public SwingDemo() throws HeadlessException
    {
        try
        {
            this.loadTableModel();
            jbInit();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    private void loadTableModel()
    {
        int columnCount = 25;
        int rowCount = 1000;

        Vector columns = new Vector();
        for (int i = 1; i <= columnCount; i++)
        {
            String val = "Column " + i;
            columns.add(val);
        }

        Vector data = new Vector();
        for (int r = 0; r < rowCount; r++)
        {
            Vector row = new Vector();
            for (int c = 0; c < columnCount; c++)
            {
                String val = "value r="+r+" c="+c;
                row.add(val);
            }
            data.add(row);
        }
        DefaultTableModel model = new DefaultTableModel(data,columns)
        {
            public boolean isCellEditable(int r, int c)
            {
                return false;
            }
        };
        table.setModel(model);
    }

    public static void main(String[] args) throws HeadlessException
    {
        SwingDemo bugDemo = new SwingDemo();
        bugDemo.setSize(Toolkit.getDefaultToolkit().getScreenSize());
        bugDemo.setLocation(0, 0);
        bugDemo.setVisible(true);
    }

    private void jbInit() throws Exception
    {
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
        jScrollPane1.getViewport().add(table, null);
    }

}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use the 1.4.2 JVM

Release Regression From : 5.0
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2005-05-16 06:48:15 GMT

Comments
EVALUATION This is a duplicate of 6195469. The described behavior happens because of a bug where table clears the existing selection if the mouse is dragged. Even a one-pixel move of the mouse will cause the selection to be cleared. Closing as a duplicate and upping the priority of the other bug. ###@###.### 2005-07-20 17:43:39 GMT
20-07-2005