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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -