• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ComboBox in JTable

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I Created a JTable in that one column is a JComboBox. I want the drop down of combobox to be appeared when i press the down arrow key.(dropdown is coming when i click on it with mouse)
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
To do that you'll have to add a KeyAdapter to the JTable. Then in the keyPressed method of the KeyAdapter check the code of the key pressed like this:
If you ONLY want the arrow-down key to act on the comboBox you'd have to extend the JComboBox class and change that behaviour.

Hope that helps,
Terry
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramana,

Please re-register with a user name that follows the guidelines in the Official JavaRanch User Name Convention. Your user name is required to be in the format "First Name" + space + "Last Name".

Thanks,

-Nate
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Terence Doyle:
HI,
To do that you'll have to add a KeyAdapter to the JTable. Then in the keyPressed method of the KeyAdapter check the code of the key pressed like this:
If you ONLY want the arrow-down key to act on the comboBox you'd have to extend the JComboBox class and change that behaviour.

Hope that helps,
Terry

 
Chikoo V
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Terence Doyle:
HI,
To do that you'll have to add a KeyAdapter to the JTable. Then in the keyPressed method of the KeyAdapter check the code of the key pressed like this:
If you ONLY want the arrow-down key to act on the comboBox you'd have to extend the JComboBox class and change that behaviour.

Hope that helps,
Terry



Hi
But this code doesnt seem to work for me.Have got the same problem but the piece of code that u have posted doent seem to work for me.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic