java - How to convert from String[] to JTextField[] -
i trying make jtextfield array based on word length input file. can't seem find way convert string[] jtextfield[].
//splits word chosen word list array jtextfield[] wordamount = new jtextfield[word.length()];//creates jtextfield each letter string[] items = word.split(""); string temp; (int j = 0; j < items.length; j ++) { temp = items[j]; wordamount[j].settext(temp); }
you need initialize each jtextfield in jtextfield array before call method before call settext() method add statement
wordamount[j] = new jtextfield();
so change loop this
for (int j = 1; j < items.length; j++) { temp = items[j]; wordamount[j] = new jtextfield(); wordamount[j].settext(temp); }
Comments
Post a Comment