This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Disabling an entire JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Disabling an entire JTable" Watch "Disabling an entire JTable" New topic
Author

Disabling an entire JTable

Sumitra Venkat
Greenhorn

Joined: Apr 07, 2001
Posts: 5
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

Joined: May 17, 2001
Posts: 2823
table.setRowSelectionAllowed(false);
table.setColumnSelectionAllowed(false);
Sumitra Venkat
Greenhorn

Joined: Apr 07, 2001
Posts: 5
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

Joined: Jun 21, 2001
Posts: 57

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

Joined: Jul 06, 2001
Posts: 313

> 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

Joined: May 09, 2001
Posts: 92
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Disabling an entire JTable