Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Using SQL to auto populate Jfields from comobBox item

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 24837
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Taylor Manley
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Paul Clapham
Marshal
Posts: 24837
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
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!