JComboBox as editor in JTable

Hi,

I have used JComboBox as editor for cell in one of the columns in JTable.

And to that JComboBox I have set the Editor by extending the BasicComboBoxEditor class in which I used JFormattedTextField as an editor. ie I have set the JFormattedTextField as an editor for JComboBox and then JComboBox as an editor for table column cell. Got it!

Now here;s the problem, when the cell is editable and combobox is having focus by using down arrow button it shows the drop down list and i can scroll it by pressing down arrow button. Now if i hit enter button it is not selecting the value and does nothing. Is there any techinical reason for this.

I want that when I press Enter or tab after scrolling using down arrow button it should select currenlty highlited item. Rest of the work is done.

Thanks and regards

Nilesh

[858 byte] By [Nilesh_Boradkara] at [2007-9-30 2:22:11]
# 1

Hello there

I had a similar problem and I spent ages trying to figure it out. I take it the cell you are trying to edit is already empty. What it is, while you have a cell editor on the cell in question, you dont have a cell renderer which is responsible for actually drawing the selected item in the cell once the editing combobox has closed. The way I found around this problem was to fill the cells of the table with some default data when the table is initalised, this meant that a suitable renderer for the type of data I was trying to display was automatically assigned.

Hope this helps

fypstudenta at 2007-7-16 13:31:32 > top of Java-index,Archived Forums,Swing...