• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 516
  • Last Modified:

control+uparror/downarrow on jtable does not select multiple items !

The java documentation says that on jtable we can select
multiple rows ( that are not continuous) by pressing control and up/down arrow.

However  it is not working for me !

Any suggestion is welcomed.

I am positing a sample code here. You can just compile it
and run to diaply a simple jtable.
Save the code is testTableApp.java

Thanks
0
MFC123
Asked:
MFC123
  • 4
  • 4
1 Solution
 
MFC123Author Commented:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

import javax.swing.JTable;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import javax.swing.table.AbstractTableModel;


class testTableApp extends JFrame
{
 static
 {
   try
   {
     UIManager.setLookAndFeel(
     UIManager.getSystemLookAndFeelClassName());
   }
   catch (Exception e) { }
 }


 testTableApp()
 {
   JPanel contentPane = (JPanel)getContentPane();
 
   TableModel dataModel = new AbstractTableModel() {
          public int getColumnCount() { return 10; }
          public int getRowCount() { return 10;}
          public Object getValueAt(int row, int col) { return new Integer(row*col); }
      };
      JTable table = new JTable(dataModel);
      JScrollPane scrollpane = new JScrollPane(table);
 
 
    contentPane.add(scrollpane );  

   setSize(200,200);    
   setVisible(true);

 }
 
 public static void main(String args[])
 {
   testTableApp  testApp = new testTableApp();
 }    
 
}
0
 
yongsingCommented:
I tried your program on Win2K, and I don't have a problem selecting multiple rows with Ctrl + Up/Down keys. This should be the default behaviour. You may want to set it to multiple selection mode as follows:

table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

Actually, you don't really have to do this as multiple selection is the default.
0
 
MFC123Author Commented:
yongsing, which java version do u have ?

Here is mine

java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
yongsingCommented:
I use 1.4.1. The default should be multiple selection, regardless of the version. Did you trying setting the selection mode explicitly?

table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0
 
MFC123Author Commented:
Yeah, I did try setting multiple_interval_selection and it did not work.
0
 
yongsingCommented:
That's strange then. Are you selecting multiple rows by pressing the Ctrl key and the Up/Down key at the same time? Did you try using the Shift key as well?
0
 
MFC123Author Commented:
Shift key will select continuous blocks, but i want to select bloks of items that are not continuous.
Yes I am pressing control+up/down at the same time.
0
 
yongsingCommented:
Sorry, I don't really know why it's not working for you. I'm beginning to suspect that your Ctrl key is not working? :)
0
 
SpideyModCommented:
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now