• 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
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Populate JComboBox with mysql

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to implement a JComboBox into my eclipse gui. My end goal is to have two drop down combo boxes that compare videos on favorites list between two users. I am trying to populate a combobox with my databases now but I'm running into errors. The code I'm working with for the combo box is




But I'm getting an error that "comboBox_1" can not be resolved.


What am I doing wrong?
 
Sheriff
Posts: 24743
59
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It says you're using comboBox_1 as a type, but you haven't declared it as a type. And you have:



I think you meant to use the addItem() method of JComboBox here.

By the way can I suggest you use the try-with-resources statement for your JDBC code? It would look more like this:



As you can see, it takes care of all the tedious finally-clauses and resource-closing for you. I also removed the code where you caught an exception and did nothing but throw the exception. There's no point in doing that because the exception is going to be thrown anyway.
 
Trust God, but always tether your camel... to this tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!