Even I was confused why this problem occurred to me. I mean, I have another JComboBox cell editor used in another JTable and there was no problem with the selection highlight when I pressed either the up or down arrow key to navigate through the items.

i double checked line by line and compared my two classes to ensure that there is nothing different with the two of them. And still, the selection highlight problem persisted.

Luckily, there is a property that you can set to a JComboBox cell editor to highlight the selected item when you use the up and down arrow keys.

If you encounter this problem, avoid debugging your code and use this property right away. It took me some time to find out the solution but the fix is pretty quick.

If you use a JComboBox as a cell editor in a JTable and you get this error message “component must be showing on the screen to determine its location”, chances are your cell editor is inherited from DefaultCellEditor. Thomas Bang saved us all the trouble in trying to figure out how to make a workaround for this problem by creating a ComboBoxCellEditor class inheriting from AbstractCellEditor.

Pretty cool. This class actually did the trick.

Related Posts Plugin for WordPress, Blogger...