• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jtable selecting only one column

 
Steffen K
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
i have a table with 2 columns... at the moment both columns are editable. lets describe my problem:
i only want to edit the second column. the first column should be static...
i tried the method:
-> setEditingColumn( 2 ); but nothing special happened?
can anybody outthere help me?
greetings
Steffen
 
Laurent Leonard
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use a tableModel implementing the method isCellEditable

Example
class YourTableModel extends AbstractTableModel
{
public boolean isCellEditable(int row, int col)
{
boolean isCellEditable;
isCellEditable = (col==1) | | (col==3);
/* I think the column numering is from 0 to n-1 if n
columns in table */
return isCellEditable;
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic