Populating a jcombobox with database information?

A few points: Wading through your code, I don't see a call to initData being made anywhere. Without that call, you won't call your database code. Without the database call, you won't get the data JComboBox does not have a setModel method that takes an array.

You can wrap your array in a DefaultComboBoxModel and set that on the model It is good to keep in mind that blocking calls like database access should not be made in the AWT painting thread, and neither should calls that update the GUI be made outside of the AWT thread. You should look into creating your GUI and grabbing your data in separate threads, and making use of SwingUtlities. InvokeLater or similar tools to update your GUI.

A few points: Wading through your code, I don't see a call to initData being made anywhere. Without that call, you won't call your database code. Without the database call, you won't get the data.

JComboBox does not have a setModel method that takes an array. You can wrap your array in a DefaultComboBoxModel and set that on the model. It is good to keep in mind that blocking calls like database access should not be made in the AWT painting thread, and neither should calls that update the GUI be made outside of the AWT thread.

You should look into creating your GUI and grabbing your data in separate threads, and making use of SwingUtlities. InvokeLater or similar tools to update your GUI.

There is too much code there to look at 90% of it is NOT related to adding data in a combo box. You have a dozen other components which clutter the code so we can't see what actually happening with the comobo box. It you really need help then post a SSCCE.

That is, create a simple frame and load hard coded data into the combo box. Then create a simple program to read data from the database and use System.out. Println(...) to display each value.

Once you've mastered the two basic steps, then put the two programs together to load a combobox dynamically from a database. Finally add the rest of you components to the frame. Break you problem down into small, manageable steps and you will be able to debug it easier.

CreateTitledBorder(null, "Billing Information", javax.swing.border.TitledBorder. ABOVE_BOTTOM, new java.awt. GroupLayout jPanel1Layout = new javax.swing.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions