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.
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!