I am trying to implement a code that allows the user to choose the name of a video from a comboBox and then have sql return the values from the database that correspond the the txtfields. My sql statement for the combobox was returning values until I added an ActionEvent and now I'm not getting any values. I've alternated between SELECT * and SELECT video_name, but neither return anything in the drop down.
Taylor Manley wrote:My sql statement for the combobox was returning values until I added an ActionEvent and now I'm not getting any values.
Okay. So now your SQL code will be executed when an action event is triggered by the combo box. What are you (as the user, not the programmer) doing to the combo box to make it trigger an action event?
I suspect you aren't doing anything, because it's empty. So therefore the SQL code never runs.
I expect your plan involves the user doing something to the GUI to cause the SQL to run? If so then you're going to need a JButton or something like that. However if your plan was for that code to run at the time of initialization, then it should just be run by the initialize() method.
posted 1 month ago
I want the sql statement to run upon the interface loading so that the comboBox displays the video names when the user clicks on it and then from what they click I want the Jfields below it to be populated with the values from the database. So I didn't plan on having a button really. So for that I should initialize the comboBox instead of having an ActionEvent?
Yes. An action listener is used to deal with the situation where a person looking at the GUI does something with the mouse or keyboard to a component. That isn't what you want, you want to load the table from the database while you're initializing the GUI.
I'm so happy! And I wish to make this tiny ad happy too: