| | |
Dynamic JPanel additions to a JFrame/JPanel
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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
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
Regards
Shouvik
Shouvik
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
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
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Other Threads in the Java Forum
- Previous Thread: Need help with Java project
- Next Thread: is it possible to run the java application in a mysql linux server
| Thread Tools | Search this Thread |
-xlint add android api applet application array arrays automation bi binary blackberry bluetooth chat class classes client code compile compiler component converter database digit draw eclipse equation error event exception fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying oracle page pearl print problem program programming project qt recursion scanner screen server set size sms sort spamblocker sql string swing system thread threads time tree variablebinding windows xor






