I'm having issues with the following code, where I use a JComboBox to change a String value in a table cell. The JComboBox works fine, but if I click in the box and then click away without selecting anything the JComboBox's dropdown remains visible, even if I delete the row. Clicking on another Swing component like a JButton often causes it to go away, but not always.
TableColumn col = myTable.getColumnModel().getColumn(0);
JComboBox eq = new JComboBox();
eq.addItem("==");
eq.addItem("!=");
DefaultCellEditor editor = new DefaultCellEditor(eq);
col.setCellEditor(editor);
Edit: I had neglected to mention that earlier I set:
myTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
If I comment this line out or set it false, then clicking on other Swing components does NOT cause the box to vanish. With it in, clicking on anything that takes focus causes the box to go away, making the problem less annoying but possibly masking the cause of the behavior.
Am I doing something wrong here, or forgetting a step? Alternately, is there a way to force it to close itself?
Thanks!