File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How i can dynamically add the child components to jpanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How i can dynamically add the child components to jpanel " Watch "How i can dynamically add the child components to jpanel " New topic
Author

How i can dynamically add the child components to jpanel

nand rai
Greenhorn

Joined: Feb 17, 2009
Posts: 27
How i can dynamically add the child components to jpanel

I have jpanel

and many lables,text feilds, check boxes, multi select and others.

How can i dynamiclly add all the elements to jpanel.

I want to avoid the following

this.add(jLabelB);
this.add(imageSeqComboBox, null);
this.add(jLabel0, null);
//this.add(txtImageLocator, null);
//this.add(jLabel3, null);
this.add(txtSerialNumber, null);
this.add(jLabel2, null);
this.add(txtAmount, null);
this.add(jLabel11, null);
this.add(txtIssueId, null);
this.add(jLabel1, null);
this.add(txtIssueDate, null);
this.add(jLabel5, null);
this.add(txtRangeBegin, null);
this.add(jLabel9, null);
this.add(txtTotalMO, null);
this.add(jLabel4, null);
//this.add(jLabel81,null);
//this.add(txtFRBProcessDate,null);
this.add(jLabel82,null);
this.add(txtMoOrigin,null);
this.add(jLabel83,null);
//this.add(txt8105A,null);
this.add(formA,null);
this.add(formB,null);
this.add(jLabel84,null);
this.add(txtUserLastName,null);


Thanks
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
What about putting them in a Component[] and adding each element in a for loop?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How i can dynamically add the child components to jpanel
 
Similar Threads
Gridbag layout problem, element comming in center
Netbeans 5 : add component using addLayoutComponent() problem
JPanel
setting background image in applet
JScrollPane