• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disabling an entire JTable

 
Sumitra Venkat
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I need to disable an entire JTable i.e disallow the user to select any row, column or cell. Is there anyway of doing this?
Thanks in advance,
Sumitra
 
Paul Stevens
Ranch Hand
Posts: 2823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
table.setRowSelectionAllowed(false);
table.setColumnSelectionAllowed(false);
 
Sumitra Venkat
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,
Thanks for your reply, but that's not quite what I wanted. I have a ListSelectionListener attached to the JTable, that keeps track of changes in row selection and displays the selected row's details in some textfields. For a particular circumstance, I don't want these details to be displayed in the textfields and hence want the JTable to be disabled so that the user cannot perform row selections. I tried out what you had suggested, but it still triggers the row changed event and displays the selected row in the textfields.
If you/anyone has knows some way of doing this, please do write.
Thanks in advance,
Sumitra
 
Javaoops
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Check for the particular circumstance and clear the selection of the table(which deselects selected columns and rows)using
Table.clearSelection();
else
try to manipulate with
Table.getSelectionModel().setSelectionInterval(index,index);

 
San Su
Ranch Hand
Posts: 313
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

> I need to disable an entire JTable
Check out the following site..
http://www.codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=java&Number=14490&page=&view=&sb=
 
Amit Agarwal
Ranch Hand
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sumitra,
there are three default editors associated with the class types. If you remove these associations, the JTable will become read-only. You can still select the cells /cols / rows as per your settings. The code for disabling is:

-------------
Amit
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic