Hey there!

I have been trying to get all my JTable cells to be not Editable so you can't change the info displayed on the JTable. It sounds easy to do but I cant seem to do it.

Any help would be appreciated

13 Years
Discussion Span
Last Post by sdasdasd

Hi everyone,
It really depends on what your default editor component is
if your component is say a JTextArea the do the following

textarea1 = (JTextArea)table1.getEditorComponent();

One more thing do not forget to add a table listener so that no matter which cell is clicked it cannot be edited or in your initialization you can do a loop an set all cells to uneditble mode

I you have any other questions on this subject post them here

Richard West


I guess you can implement the isEditable() method in your table model and return false and you table will not be editable. Let's see a quick example

public class MyTableModel extends AbstractTableModel{

public void isEditable(){
return false;

Then you have a table and you set its model to a MyTableModel object eg.

JTable table = new JTable();
table.setModel(new MyTableModel());

Remember to implement MyTableModel well so that it will have some data. I hope this helps


Well I made my JTable non-editable by disabling it, i.e., using setEnabled(false). It works in my situation.


i dont think u understand the concept of a forum like this one. it doesnt matter how old the post is. if the matter is still relevant it is most appreciated to post a solution.

me helped this a lot so thanks for the solution.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.