Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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: 25594
69
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: 25594
69
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.
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
ScroogeXHTML 9.0 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/731949/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic