aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Regarding JComboBox in a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Regarding JComboBox in a JTable" Watch "Regarding JComboBox in a JTable" New topic
Author

Regarding JComboBox in a JTable

seema prakash
Ranch Hand

Joined: Nov 17, 2004
Posts: 59
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

Joined: Nov 17, 2004
Posts: 59
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Regarding JComboBox in a JTable