Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding JComboBox in a JTable

 
seema prakash
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have the JTable with my last column that has to be rendered as a JComboBox. But, I'm not able to expand it and select a different value. I'm not able to find out what am I doing wrong. Please can anyone help.
My code is as follows:

 
seema prakash
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did get help and the mistake was in my
class JTableButtonModel extends AbstractTableModel {
.....
public boolean isCellEditable(int row, int column) {
return false;
}
....
}


I had to change it to this

class JTableButtonModel extends AbstractTableModel {
.....
public boolean isCellEditable(int row, int column) {
// 1st solution
return true;

// or 2nd solution, make it such that only column 2 it editable
if(column == 2) {
return true;
}

return false;
}
....
}

I hope it will be helpful for someone with the similar problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic