I have a Jcombobox which appears in a column of a JTable. The values are getting initialized when the table gets displayed. But the combo box doesn't displayed unless you don't click on the column containing the combo box.
Now I want to implement two more things in it
1. When I will traverse through the table with tab key and reach to the combo box column, the combo should get displayed without clcking with the mouse. 2. After getting displyed, if I typed some characters, the value in combo box starting with that character should get automatically displayed.
I tried trapping the focus & key event of the combo box but it's not working. Please help.
Thanks in advance
posted 9 years ago
...the combo should get displayed without clcking with the mouse. The default behavior with the tab key seems to close the combo popup and I wasn't able to find an easy way around it. I tried working with keyStrokes in InputMaps with no success. There may be a way to do this with ancestor InputMap/ActionMaps and keyStrokes. If not, you may have to write some plaf code. You can open it with either the space bar or the down arrow button once you have tabbed into it. And navigating with the arrow buttons works okay. if I typed some characters, the value in combo box starting with that character should get automatically displayed This is provided for us in the JComboBox class and is handled by its nested class DefaultKeySelectionManager (see source code). The code below uses it. If this doesn't meet your needs you can make your own class to implement the JComboBox.KeySelectionManager nested interface and set it on the comboBox editor component (indicated below). Although I don't count this as completely successful (tab popup issue) it may be useful to you.