• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Disabling an entire JTable

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
table.setRowSelectionAllowed(false);
table.setColumnSelectionAllowed(false);
 
Sumitra Venkat
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);

 
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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=
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic