JTable not editable but selectable?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ron_Arrigo
Posted On:   Friday, June 29, 2001 07:33 AM

I created a JTable using the following code JTable table = new JTable(data, columns); table.setCellSelectionEnabled(false); table.getTableHeader).setReorderingAllowed(false); JScrollPane scrollPane = new JScrollPane(table); I want the user to be able to select the rows, but I do not want the use to be able to modify (edit) any of the data. I can disable the table with the table.setEnabled(false); so that the cells are not modifiable, but this also makes them not selectable. What command do I need to set all the cells in a JTable to be not modifiable? Thanks    More>>

I created a JTable using the following code


JTable table = new JTable(data, columns);

table.setCellSelectionEnabled(false);

table.getTableHeader).setReorderingAllowed(false);

JScrollPane scrollPane = new JScrollPane(table);


I want the user to be able to select the rows,
but I do not want the use to be able to modify
(edit) any of the data. I can disable the table
with the table.setEnabled(false); so that the
cells are not modifiable, but this also makes
them not selectable.


What command do I need to set all the cells in
a JTable to be not modifiable?


Thanks

   <<Less

Re: JTable not editable but selectable?

Posted By:   Anonymous  
Posted On:   Friday, June 29, 2001 09:23 PM

Click Here and you will find a question titled "How to make columns non editable for a non editable....." ,and there is a sample coding very useful to you.
Thanks & Regards

N.A.SasiVarnan

Re: JTable not editable but selectable?

Posted By:   Christopher_Brind  
Posted On:   Friday, June 29, 2001 08:39 AM

Sub class javax.swing.table.DefaultTableModel
and override the isCellEditable(int row, int column) method returning false.



Then on your JTable instance call the setTableModel() method with an instance of your sub-class. Do this before you start using the JTable!
About | Sitemap | Contact