java - manipulation with dynamically added textfield values -


jpanel consists 5 jtextfields. adding dynamically jpanels addbutton. , retrieving dynamically added jpanel values savebutton. code of savebutton:

private void writefile(jpanel panel_name, printwriter file){         component[] children = panel_name.getcomponents();                            (component sp : children) {             if (sp instanceof subpanel) {                 component[] spchildren = ((subpanel)sp).getcomponents();                   int count=1;                 (component spchild : spchildren) {                     if (spchild instanceof jtextfield) {                      string text = "";                     if(count==1)                     text=((jtextfield)spchild).gettext();                      if(count==2)                     text=((jtextfield)spchild).gettext();                      if(count==4)                     text=((jtextfield)spchild).gettext();                      if(count==5)                     text=((jtextfield)spchild).gettext();                      if(count==3)                     text=((jtextfield)spchild).gettext();                      if(text.equals(null) || text.equals("")) {                      }                        else{                     file.write(text);                                }                                                                    }                 }             }         } 

i have entered 1, 2, 4, 5, 3 jtextfields , when click savebutton, output got jtextfield values as: 1, 2, 3, 4, 5. if write count==4 after count==2, anyway output getting in ordered line. ask how can value of count==4 after count==2?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -