Hi All,

I am trying to develop an application which would use a combo box to obtain a set of records from a database table. Now on the count of number of records that are available in the table I need to populate a JPanel say Parent with another JPanel say Child which has a set of swing controls viz. checkbox, label and a TextField. The number of occurrences of this child JPanel should be equivalent to the number of records in the table.

I would also like to refresh (repaint) the Parent JPanel with newer numbers of child JPanels once somebody selects another table name from the combo box.

Can somebody help me out with this implementation

Create a class that will represent the data from the database.
Create a separate class with queries and methods that return the data from the DB.
When you open the GUI call these methods and use the data to populate the combobox.
Since you will have many Jpanels Child I would suggest to have an array of JPanel Child or a Vector. Each element will take value from the data that you will read from the database. And with the help of a for-loop you will be displaying them at the gui.

Try to divide you work. First create the class to read from the database. Then create the gui. Just the gui with no functionality just to see how it is displayed and use dummy values instead of using the database. Then after you have made sure that they work try to combine them. Since you will have a lot of stuff in the child JPanel I would suggest for you to create a new class that extends JPanel and put(add) inside it the gui elements that you need

This article has been dead for over six months. Start a new discussion instead.