Originally posted by rajesh chalavadi:
Component comp =
table.prepareEditor(table.getCellEditor(row, col), row, col);
comp.transferFocus();
That's not really what you want to do, I don't think. Instead try something like
boolean ok = table.editCellAt(row, col); // optional: show the combo box's popup
Component comp = table.getEditorComponent();
if (ok && comp instanceof JComboBox) ((JComboBox)comp).setPopupVisible(true);
While I'm here, I'm not wild about the way you've implemented your cell editor. Even if the combo box's items need to be dynamic, I'm not sure it's a good idea to instantiate a new instance of JComboBox on each call to getTableCellEditorComponent(). I would suggest creating a single JComboBox in the editor's constructor. Don't you sort of need to do that to implement getCellEditorValue() anyway? (Depending on the circumstances, you may be able to use DefaultCellEditor instead. It has a constructor that takes a JComboBox.)
[edit: now checking editCellAt()'s return value]
[ February 13, 2008: Message edited by: Brian Cole ]