How to select All JTextFields and get their text-Java -
lets have class lot of jtextfields following:
public class multiplefields{   jtextfield a=new jtextfield();  jtextfield b=new jtextfield();  jtextfield c=new jtextfield();    //there many more jtextfields in actual code   public void gettextfromfields(){     //implementation code goes here    }  } is there api,library or use text jtextfields(or else these jtextfields?)
use list<jtextfield> or array.
public class multiplefields {     jtextfield textfields = new jtextfield[700];      public multiplefields() {         (int = 0; < textfields.length; ++i) {             textfields[i] = new jtextfield();         }     }      public string alltexts() {         stringbuilder sb = new stringbuilder();         final string eol = system.getproperty("line.separator");         (int = 0; < textfields.length; ++i) {             sb.append(i).append(": ").append(textfields[i].gettext().append(eol);         }         return sb.tostring();     } 
Comments
Post a Comment