JDK-4727024 : JTable: multiple selection mode gives weird results when cell selection enabled
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-08-06
  • Updated: 2002-08-06
  • Resolved: 2002-08-06
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 08/06/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :

Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
When JTable.setSelectionMode
(ListSelectionModel.MULTIPLE_SELECTION_INTERVAL) is used
with JTable.setCellSelectionEnabled(true), CTRL+Click
selects/deselects whole rows and columns, not just cells.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Run the below program
2.Click on the top-left cell and then SHIFT+click on a cell
a few rows down and a few columns over.
3.Now CTRL+click somewhere in the middle of the selection
block.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Since I am in cell selection enabled mode I would expect
just the cell I clicked on in step 3 above to be
deselected. Instead, the whole row and column of the cell I
clicked on was deselected.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.io.*;
import java.awt.*;
import javax.swing.table.*;
import java.awt.event.*;
public class GridTest extends JFrame
{
    TestTableModel m_model;

    public GridTest()
    {
        try
        {
        setSize(200,300);
        setLocation(100,100);

        JTable table = new JTable(5,5);
        table.setCellSelectionEnabled(true);
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        
        this.getContentPane().add(table,BorderLayout.CENTER);
       
        
        }catch(Exception e){}
        
        setVisible(true);
        
    }
   

    public static void main(String[] args)
    {
        GridTest gridTest1 = new GridTest();
    }

}
---------- END SOURCE ----------
(Review ID: 160426) 
======================================================================

Comments
EVALUATION This behavior is a result of the way we model the selected data. The default table model only keeps track of which rows and columns are selected. Selected cells are just the intersection of these. There is an RFE, 4138111, which hopes to provide a model that allows for actual selection of individual cells. Closing as a duplicate. ###@###.### 2002-08-06
06-08-2002