Pages

Thursday, July 15, 2010

How to disable edit cell in JTable (especially in NetBeans)

Put this in your code:

table = new javax.swing.JTable(){
    public boolean isCellEditable(int rowIndex, int colIndex) {
        return false;   //Disallow the editing of any cell
    }
};

where table is the name of your JTable.

For NetBeans users:
1. select the table GUI, right click, select Customize Code
2. Your code should look like this:

35 comments:

Anonymous said...

Thank you! It really works. Although it's hard to find, your solution is great for NetBeans users.

jet MUSIC said...

You're welcome :)

Anonymous said...

many thanks
working ...

Zaf said...

thanks, it works for me

Tebone said...

thanks, much better than reinventing the wheel :)

Anonymous said...

Hi, thank you for your article...

Anonymous said...

Thank you so much
so helpfullness :D

Anonymous said...

Elakiri samaga nala jalaya

Anonymous said...

it really works thanks
Sadiq
hyderabad
India

Anonymous said...

Excelent!! It works perfect! Thank you!

H. MACHHOUR said...

thank you!

Anonymous said...

The other option is to override isCellEditable in your TableModel:

@Override public boolean isCellEditable(int rowIndex, int columnIndex)

Anonymous said...

oh wow, you are A SAVIOR!

Anonymous said...

Thank you very very much...

Anonymous said...

This helped me a lot, thanks.

Anonymous said...

Thanks alot

Anonymous said...

I have some problem and 've just solved it. thank u!

pradeep said...

Hello miss... i am pradeep ..i m novice in swing ...can u please explain Where i have to call the method isCellEditable()..... bcoz i used it in my program but its not working......

Unknown said...

Thank you , buddy Your solution works !!

할아버지 said...

Thank * 100 you!

ranjan singh said...

its really work thanxs alot...

ace said...

thanksss

Unknown said...

Hie Guys
In netbeans the easiest way to do it is select table properties and go to model and click the ellipses. A dialog window will show up. Just uncheck editable on Table settings and that it. You are done good luck.

Unknown said...

Thanks much helpful than StackOverflow :)

Anonymous said...

Thanks much, from Nicaragua

Aaron Jacob A. Virata said...

THANK YOU VERY MUCH!!! :D

L said...

your posting really help me alot, thanks
greeting from Indonesia :)

Reverberus said...

Hello "JET"! This post save me. Thank you very much.

Anonymous said...

cam on nhieu love u

Anonymous said...

Thank you very much! I was really trying very hard for this.

Anonymous said...

Heheheh 1000000000% helpful. Thanks. KEEP IT UP!!!

Your talent is hard to find.

Unknown said...

Thanks a lot. It perfectly works.

GHOST said...

Gracias,amigo.

Anonymous said...

Thanks so much :)

Unknown said...

Great. Thank you so much

Post a Comment