Dynamic JPanel additions to a JFrame/JPanel

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2007
Posts: 200
Reputation: shouvik.d is an unknown quantity at this point 
Solved Threads: 6
shouvik.d's Avatar
shouvik.d shouvik.d is offline Offline
Posting Whiz in Training

Dynamic JPanel additions to a JFrame/JPanel

 
0
  #1
Apr 29th, 2008
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
Regards
Shouvik
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,681
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 227
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: Dynamic JPanel additions to a JFrame/JPanel

 
0
  #2
Apr 29th, 2008
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
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC