• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable - only one read-only column

 
Leonardo Penha
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I am trying to build a JTable with only one read-only column. The other columns should be editable.
The behaviour I want is EXACTLY the same as the table in the "Proxies" tab in the Java Plug-in Control Panel (that comes with JDK 1.4) when the "Use browser settings" check box is NOT checked.
Does anyone know how to do it?
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
try this:
You should have a TableModel. Do you?
If yes, then you should have a isCellEditable Method in it, which takes a row and a column. The row doesn't matter in your case. Simply test, if the column fits to the column, which shouldn't be editable.
/*
This method would make all cells uneditable, which are in the first column.
*/
public boolean isCellEditable(int row, int col){
if (col == 1) return false;
return true;
}

Hope this helps

Rene
 
Leonardo Penha
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx. it worked
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!