Hello All, as the subject says I'm using a JComboBox as cell editor in JTable if the combobox is not editable all works perfect if I set the combo box to be editable, allowing the user to enter free form text, the user can add the text but when he moves to another cell it disapears, what else do I need to do to get it to work?? I set it up like this JComboBox combo = new JComboBox (); combo.addItem("foo"); combo.addItem("bar"); combo.setEditable(true); TableColumn col = getColumn(6); col.setCellEditor(new DefaultCellEditor(combo)); do I need to do something else?? Thanx Dave
What you are doing should work. I went to the How to Use Tables tutorial on SUN, downloaded the example that uses a combobox for an editor (TableRenderDemo.java) and added "comboBox.setEditable(true);" to the source. It compiled and worked just fine, meaning I could select a value from the dropdown list, or enter a new value, and the table was updated accordingly. Is it possible that there's something funny in the "setValueAt(...)" method (of your Model class) that checks the new value and throws it away if it doesn't match what is in the list? That would explain the behavior.
Joined: Sep 16, 2003
OUCH!! as you noted, my example works perfectly with a JTable I should have explained in more detail I'm actually using a third party table that is derived from a JTable apparently the third party class is the problem I went back and tried it with plain old JTable and it works fine shoulda done that in the first place thanx for helping me figure it out time for third party tech support :roll: Dave