• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JComboBox in a JTable

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...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.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic