• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Piet Souris

Populate JComboBox with mysql

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?
Posts: 25135
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.
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!