• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How i can dynamically add the child components to jpanel

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about putting them in a Component[] and adding each element in a for loop?
 
reply
    Bookmark Topic Watch Topic
  • New Topic