?
Solved

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

Posted on 2003-02-19
9
Medium Priority
?
514 Views
Last Modified: 2012-06-27
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
Comment
Question by:MFC123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 1

Author Comment

by:MFC123
ID: 7984797
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
 
LVL 9

Expert Comment

by:yongsing
ID: 7984901
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
 
LVL 1

Author Comment

by:MFC123
ID: 7985023
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Expert Comment

by:yongsing
ID: 7986117
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
 
LVL 1

Author Comment

by:MFC123
ID: 7988579
Yeah, I did try setting multiple_interval_selection and it did not work.
0
 
LVL 9

Expert Comment

by:yongsing
ID: 7991083
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
 
LVL 1

Author Comment

by:MFC123
ID: 7996063
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
 
LVL 9

Expert Comment

by:yongsing
ID: 8002604
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
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8066567
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question