• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Searchable JCombobox

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a java based software connected with a mysql database. I have an Item table in my database. I created a bean class which can keep all item data with it and. Then I loaded each Item data in to its object and fill a Jcombobox. Now I want to search with Item name and get all Item data when selecting that item. I have overidden the toString method to Item name in that class. Is there any way to search my Item objects inside a jcombobox? Thanks.
 
Ranch Hand
Posts: 30
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well first welcome to the ranch!

Next, if you put the items into a List or array before you added them to the JComboBox you could iterate over that and search for your item.

The only ways i can think of accessing items in the combo box is to get the selected item or at item at a given index.

If you wanted you could use getItemCount() method to get the number of items and then loop through the items one at a time to find your item.
I don't think that would be good practice though.


Hope that helps.


-Jarrod

 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain without reference to your current design what you want to happen. For example when the user clicks on an entry in the combox box I want to ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!