Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JComboBox in a JTable

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Would you like to try a free sample? Today we are featuring tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic