Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

editable  RSS feed

 
amol bakre
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!!
please can someone tell me how to set the whole of the JTable
(all the cells) totally uneditable that is if it can b done!!
thank you
 
Jagan Mohan Reddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Override the table class which you are using with the method
public boolean isCellEditable(int row,int column) {

// Using this method you can override any particular cell. If you want to the whole JTable to be uneditable say

return false.

}

I am also sending the sample code
JTable table = new JTable(4,4) {

public boolean isCellEditable (int row,int column) {

return false;
}

};
Regards,
Jagan Mohan Reddy
 
amol bakre
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
thank you Jagan ,your suggestion helped me and now the table is uneditable!!
Thank you
amol
 
Rambo Rambabu
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I need to set a column as editable or not at runtime instead of desging/coding time. for example, after i populate the table, I need to set columns 1 and 5 as editable for one particular condition and columns 3 and 4 as editable for another condition etc.
Any help is appreciated.
-- rambo
 
Bhagya Tangutur
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lets go back to isCellEditable() method..

public boolean isCellEditable (int row,int column) {
if((column==3 || column==4)&& yourCondition1==true){
return true
}
if((column==5 || column==6)&& yourCondition2==true){
return true
}
return false;
}
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!